The SHComponent inheritance API (derives from SHDistributableObject -> BArchivable)

The SHComponent class represents an object that can be transported to any node in the SockHop tree, and added on to it as a component.  It includes an API that allows limited access to the node that the SHComponent is running as a part of.  SHAccessPolicy's, SHWorkers, and SHSorters all inherit from SHComponent, so these types of object may make use of the methods in this API.  Those methods are:



const char * GetNodeName() const

This method returns the name of the node this component is running on.  (So, if the nodepath of the node is "/this/is/the/path", then this method would return the string "path")  The returned string belongs to the host node, and should not be deleted, freed, or written to.  This method returns NULL if this SHComponent isn't currently running on a node.
 



const char * GetNodePath() const

This method returns the full, absolute nodepath of the node this component is running on.  The returned string belongs to the host node, and should not be deleted, freed, or written to.  This method returns NULL if this SHComponent isn't currently running on a node.  (Click here for info on what the absolute node path looks like).
 



BMessenger GetNodeMessenger() const

Returns a BMessenger that can be used to post BMessages into the SockHop tree network.  BMessages sent to this BMessenger undergo the same sort of forwarding and processing as BMessages sent to the root node BLooper (you know, the one returned by SHCreateRootNode()), except that they start their journey through the tree on the local node, rather than the root node.
 


In addition to the above methods, the SHComponent class defines one abstract method that must be implemented by everything that inherits from SHComponent:



virtual const char * GetName() const=0

This method should be overridden to return a string that identifies this SHComponent.  See the documentation for SHSorter and SHWorker for details on how this string should be chosen.