User Tools

Site Tools


at:introduction

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
at:introduction [2007/04/11 12:42] tvcutsemat:introduction [2007/06/19 16:48] tvcutsem
Line 40: Line 40:
      
   // engage in peer-to-peer service discovery   // engage in peer-to-peer service discovery
-  defstripe InstantMessenger;+  deftype InstantMessenger;
   export: remoteInterface as: InstantMessenger;   export: remoteInterface as: InstantMessenger;
   whenever: InstantMessenger discovered: { |messenger|   whenever: InstantMessenger discovered: { |messenger|
Line 51: Line 51:
 An instant messenger object is created by invoking a function called ''createInstantMessenger''. A ''username'' should be passed to identify the user. The function defines two nested objects named ''localInterface'' and ''remoteInterface''. As their names indicate, the ''localInterface'' defines all of the methods that can be invoked by local objects referring to the instant messenger (e.g. by a GUI object that provides the user interface for the messenger). That's why the ''localInterface'' object is also the return value of the ''createInstantMessenger'' function. The ''remoteInterface'' provides the methods that may be invoked by remote objects (i.e. other instant messengers). In a sense, the remote interface defines the //protocol// that the messengers will use to exchange simple text messages. An instant messenger object is created by invoking a function called ''createInstantMessenger''. A ''username'' should be passed to identify the user. The function defines two nested objects named ''localInterface'' and ''remoteInterface''. As their names indicate, the ''localInterface'' defines all of the methods that can be invoked by local objects referring to the instant messenger (e.g. by a GUI object that provides the user interface for the messenger). That's why the ''localInterface'' object is also the return value of the ''createInstantMessenger'' function. The ''remoteInterface'' provides the methods that may be invoked by remote objects (i.e. other instant messengers). In a sense, the remote interface defines the //protocol// that the messengers will use to exchange simple text messages.
  
-Within the lexical scope of the ''createInstantMessenger'' function, we also define a //stripe// named ''InstantMessenger'' which will be used to identify remote objects in the network as peer instant messengers. Stripes are simply symbolic marks that can be attached to objects to classify them. They replace the role of classes in class-based OO languages to classify objects. The advantage over classes is that an object can be classified under multiple stripes (unlike classes, stripes do not say anything about the implementation of an object). A few lines down, you'll notice that the nested ''remoteInterface'' object is **exported** as an ''InstantMessenger''. This means that the object is //published// on the network as an instant messenger peer. The next line of code shows AmbientTalk's built-in discovery mechanism at work: the instant messenger asks the AmbientTalk interpreter to be notified whenever an object exported as an ''InstantMessenger'' becomes available in the network. Yes, service discovery in ad hoc networks can be as simple as this.+Within the lexical scope of the ''createInstantMessenger'' function, we also define a //type tag// named ''InstantMessenger'' which will be used to identify remote objects in the network as peer instant messengers. Type tags are simply symbolic marks that can be attached to objects to classify them. They replace the role of classes in class-based OO languages to classify objects. The advantage over classes is that an object can be classified under multiple type tags (unlike classes, type tags do not say anything about the implementation of an object). A few lines down, you'll notice that the nested ''remoteInterface'' object is **exported** as an ''InstantMessenger''. This means that the object is //published// on the network as an instant messenger peer. The next line of code shows AmbientTalk's built-in discovery mechanism at work: the instant messenger asks the AmbientTalk interpreter to be notified whenever an object exported as an ''InstantMessenger'' becomes available in the network. Yes, service discovery in ad hoc networks can be as simple as this.
  
 The ''buddyList'' variable will map the names of connected buddies to remote references to the ''remoteInterface'' objects of other instant messengers. The ''TextMessage'' object is a simple object that encapsulates a text string and the username of the sender. The ''buddyList'' variable will map the names of connected buddies to remote references to the ''remoteInterface'' objects of other instant messengers. The ''TextMessage'' object is a simple object that encapsulates a text string and the username of the sender.
at/introduction.txt · Last modified: 2008/07/15 12:19 by tvcutsem