Package spoon :: Package messaging :: Module messagingcore :: Class Messaging
[hide private]
[frames] | no frames]

Class Messaging

source code

object --+
         |
        Messaging
Known Subclasses:
SingletonMessaging

This is the main messaging class that implements the basic functionality for Spoon. Messaging implementations that need specific functionality (such as reliablility) will probably want to subclass from this.

There may be multiple instances of Messaging per python process, however there should only be one per network to which a node is a member. There may be a case where one would want a single Messaging instance shared between networks however, and as long as the node ids on the networks do not overlap, you shouldn't have any problems.

You cannot use the acceptMsg decorator with this, for that you have to use the SingletonMessaging class. To register handlers with instances of Messaging, you must use the registerHandler method on the Messaging instance.

Instance Methods [hide private]
  __init__(self, network=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
  registerHandler(self, msgtype, handler)
  unregisterHandler(self, msgtype, handler)
  handleMessage(self, src, msg)
Calls the all handlers for the given message.
  setNetwork(self, network)
  send(self, dst, messageStr, obj)
Sends a Messaging message (not just a NetMessage) to the destination node.

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__


Properties [hide private]

Inherited from object: __class__


Method Details [hide private]

__init__(self, network=None)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

registerHandler(self, msgtype, handler)

source code 
None

unregisterHandler(self, msgtype, handler)

source code 
None

handleMessage(self, src, msg)

source code 
Calls the all handlers for the given message.
Parameters:
  • src - The source node of the message
  • msg - A list containing the message type, and the attached object.

setNetwork(self, network)

source code 
None

send(self, dst, messageStr, obj)

source code 
Sends a Messaging message (not just a NetMessage) to the destination node.
Parameters:
  • dst - Destination node id
  • messageStr - A string describing the message type.
  • obj - Some object attached the net message.