2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								! Copyright (C) 2007 Chris Double. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								! See http://factorcode.org/license.txt for BSD license. 
							 
						 
					
						
							
								
									
										
										
										
											2010-09-20 15:17:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								USING:  channels  concurrency.distributed  help.markup  help.syntax 
							 
						 
					
						
							
								
									
										
										
										
											2010-09-27 20:12:33 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								io.servers ;
 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								IN:  channels.remote 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								HELP:  <remote-channel> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $values { "node"  "a node object"  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          { "id"  "the id of the published channel on the node"  } 
							 
						 
					
						
							
								
									
										
										
										
											2008-12-16 02:12:36 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          { "remote-channel"  remote-channel }
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $description "Create a remote channel that acts as a proxy for a " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								"channel on another node. The remote node's channel must have been " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								"published using "  { $link publish } " and the id should be the id " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								"returned by "  { $link publish }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $examples 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-11 22:36:40 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  { $code "\"localhost\" 9000 <node> \"ID123456\" <remote-channel> \"foo\" over to"  }
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $see-also publish unpublish } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								HELP:  unpublish 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $values { "id"  "a string"  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $description "Stop a previously published channel from being " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								"accessible by remote nodes." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $examples 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-11 22:36:40 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  { $code "<channel> publish unpublish"  }
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $see-also <remote-channel> publish } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								HELP:  publish 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $values { "channel"  "a channel object"  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          { "id"  "a string"  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $description "Make a channel accessible via remote Factor nodes. " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								"An id is returned that can be used by another node to use "  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $link to } " and "  { $link from } " to access the channel." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $examples 
							 
						 
					
						
							
								
									
										
										
										
											2007-12-11 22:36:40 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  { $code "<channel> publish"  }
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $see-also <remote-channel> unpublish } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								ARTICLE: { "remote-channels"  "remote-channels"  } "Remote Channels" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								"Remote channels are channels that can be accessed by other Factor instances. It uses distributed concurrency to serialize and send data between channels." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$nl
							 
						 
					
						
							
								
									
										
										
										
											2010-09-20 15:17:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								"To start a remote node, distributed concurrency must have been started. This can be done using "  { $link start-server } "." 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								$nl
							 
						 
					
						
							
								
									
										
										
										
											2010-09-20 15:17:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ $snippet "\"myhost.com\" 9001 start-server"  } 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								$nl
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								"Once the node is started, channels can be published using "  { $link publish }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								" to be accessed remotely. "  { $link publish } " returns an id which a remote node " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								"needs to know to access the channel." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$nl
							 
						 
					
						
							
								
									
										
										
										
											2009-10-29 21:25:10 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ $snippet "<channel> dup [ from . flush ] curry \"test\" spawn drop publish"  }
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								$nl
							 
						 
					
						
							
								
									
										
										
										
											2009-10-29 21:25:10 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								"Given the id from the snippet above, a remote node can put items in the channel (where 123456 is the id):" 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								$nl
							 
						 
					
						
							
								
									
										
										
										
											2009-10-29 21:25:10 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ $snippet "\"myhost.com\" 9001 <node> 123456 <remote-channel>\n\"hello\" over to"  } 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-01-14 16:42:21 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								ABOUT: { "remote-channels"  "remote-channels"  }