To easily specify the characteristics of a node in the tree, SockHop defines the class SHNodeSpec. Note that an SHNodeSpec is not necessarily a reference to any particular existing node in the tree; rather, it is a set of values that specify how a node or connection can be made. Each SHNodeSpec object holds the following information:
They also have some niceties defined
like Gets and Sets for all the fields mentioned above, copy constructors,
and some operators defined for them. All of these features should
be self-explanatory.
Default constructor, creates object with all fields empty
Copy constructor - creates a clone of (copyMe)
Constructors that specify a child node that runs in the same process
space as its parent.
Constructors that specify a child node that runs remotely, via TCP,
on a specified host.
Assignment operator.
Comparison operator. Note: The (specMsg) fields of the two
objects are NOT examined as part of this comparison!
Comparison operator. Note: The (specMsg) fields of the two
objects are NOT examined as part of this comparison!
Returns true only if the node name field of this object is valid.
Validity means: the node name may not be equal to "", "." or "..",
and it may not have a '/' character in it, nor may it be longer than SH_MAX_NODENAME_LENGTH
bytes.
These methods implement the BFlattenable interface for SHNodeSpec. They all work as you would expect.
Sets the hostname field of this object. An internal copy of the
string is created and retained.
Returns a pointer to the host name string held by this SHNodeSpec.
String will be valid till this object is destroyed, or SetHostName() is
called on it. Guaranteed to never return NULL (returns "" if unset)
Sets the node name field of this object. An internal copy of the
string is created and retained.
Returns a pointer to the node name string held by this SHNodeSpec.
String will be valid till this object is destroyed, or SetNodeName() is
called on it. Guaranteed to never return NULL (returns "" if unset)
Sets the port number field of this SHNodeSpec to (newPortNum).
Returns the port number of this SHNodeSpec. By default, this field is set to the value SH_DEFAULT_PORT, as defined in <sockhop/SockHopConstants.h>
Returns a reference to the held BMessage. User code may read or
write this message any way it likes.
This BMessage may be used by the SHAccessPolicy objects running on
the SockHop servers to decide whether or not your connection
is worthy of continuing. For example, the SHDefaultAccessPolicy
object often looks up the string field "password" in this BMessage.
Same as GetSpecMessage(), but returned as a const reference, so you
can't write to it.
Dump the state of the SHNodeSpec to stdout