|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--scorej.external.CommProtocol
|
+--scorej.external.socket.SignalServer
This is the Cap Socket implementation of the CommProtocol. It is initiated when SignalServer.startServer is called by startProtocol(). The port parameter tells what port to open the ServerSocket on. The SignalServer will then spawn a Thread that listens for connections. Any external node that connects has a CapConnection created. Under this scheme, every node must open a socket connection to all other nodes it wants to talk to. This leads to n^2 sockets for a fully connected network. This Protocol is meant to be compatible with the old Lisp OMAR Caps. Nodes that connect can also send a registration message, just as the old Caps in the Lisp versions of Omar. A node can register as either an External Cap, Application Cap, or Gui Cap, or as none of the above. Registering as a specific Cap type will cause a filter to be automatically created with the subject set to "EXTERNAL", "APPLICATION", or "GUI". Signals sent with the old sendSignalExternal, sendSignalApplication, or sendSignalGui will have the subject fields set appropriately. Registering as none-of-the-above means that you need to specify your own filters if you want to get any messages. There are 2 special filter messages you can send over the CapConnection. One is a DistOmarEvent_Client with a type of DISTOMAREVENT_CLIENT_KIND_FILTER. The argument of this event should be a Vector, consisting of three Vectors, which create a Filter object. See Filter.java for details. The second message type is also a DistOmarEvent_Client, with a type of DISTOMAREVENT_CLIENT_KIND_CLEAR_FILTER. Sending this message will clear all filters. Note, that when a CapConnection has no filters up, it will get no messages.
Filter| Field Summary |
| Fields inherited from class scorej.external.CommProtocol |
_props |
| Constructor Summary | |
SignalServer()
Default constructor. |
|
| Method Summary | |
boolean |
acceptConnection(CapConnection cc)
Placeholder function. |
void |
changeFilters(java.util.Vector newFilters)
Changes the signal filters associated with the local node to the new set specified in the arguments. |
void |
changeFilters(java.util.Vector newFilters,
Node n)
Changes the signal filters associated with the node (local or remote) to the new set specified in the arguments. |
void |
closeAllConnections()
Close all remote connections to the SignalServer, by calling closeConnection on all the CapConnection objects. |
void |
closeProtocol()
Extends CommProtocol.closeProtocol. |
CapConnection |
connectToNode(java.lang.String remoteHost,
int remotePort)
Connect to a remote SignalServer and register as the default CapConnection.TYPE_VALUE type. |
CapConnection |
connectToNode(java.lang.String remoteHost,
int remotePort,
int type)
Connect to a remote SignalServer and register with the specified type. |
CapConnection |
connectToNode(java.lang.String remoteHost,
int remotePort,
java.lang.String name)
Connect to a remote SignalServer and register as the default CapConnection.TYPE_VALUE type. |
CapConnection |
connectToNode(java.lang.String remoteHost,
int remotePort,
java.lang.String remoteName,
int type)
Connect to a remote SignalServer and register with the specified type. |
java.util.Vector |
findAllAgents(AgentID ignore)
Returns all registered agents that match the specified template. |
AgentID |
findSingleAgent(AgentID template)
Tries to find a registered agent based on the specified template. |
java.util.Properties |
getDefaultProperties()
Implements CommProtocol.getDefaultProperties. |
java.lang.String |
getHost()
Getter for name of host machine running the SignalServer. |
Node |
getLocalNode()
Gets a reference to the local Node object. |
java.util.Vector |
getNodes()
Return a vector of Nodes. |
int |
getPort()
Getter for the listen port of the Signal Server. |
void |
initializeProtocol(java.util.Properties props)
Implements CommProtocol.initializeProtocol(Properties). |
void |
registerAgent(AgentID ignore)
Registers an agent. |
void |
registerFilter(Filter filter)
Register a new filter for this node by sending an ADD_FILTER message to all connected Score nodes. |
void |
registerFilter(Filter filter,
Node node)
Register a new filter for a node. |
protected void |
reporter(int level,
java.lang.String message)
Wrapper around ScorejLog.log. |
void |
run()
Main socket accept thread code. |
void |
sendSignal(Node node,
Signal signal)
Send a signal to a remote Node. |
void |
shutdownHandler()
Shutdown handler will be called when the JVM exits, such when after pressing Ctrl-C on a java process running in the foreground in a console window. |
void |
signalEventApplication(Node node,
Signal signal)
Deprecated. |
void |
signalEventExternal(Node node,
Signal signal)
Deprecated. |
void |
signalEventGui(Node node,
com.bbn.omar.guiclient.DistOmarEvent_Gui guiEvt)
Deprecated. |
void |
startProtocol()
Implements CommProtocol.startProtocol(Properties). |
boolean |
unregisterAgent(AgentID ignore)
De-registers a previously registered agent. |
void |
unregisterAllAgents()
De-registers all registered agents. |
void |
update()
Upload any modifications to this node's attributes to the network. |
void |
waitForConnection(int conns)
Blocks until the specified number of client connections have been established to this SignalServer. |
| Methods inherited from class scorej.external.CommProtocol |
getProperties, isEnabledRegisterAgent, isEnabledRegisterFilter, setEnabledRegisterAgent, setEnabledRegisterFilter, setProperties |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public SignalServer()
| Method Detail |
public void update()
CommProtocol
update in class CommProtocolpublic void initializeProtocol(java.util.Properties props)
initializeProtocol in class CommProtocolprops - protocol properties, can be null or empty.public void startProtocol()
startProtocol in class CommProtocoljava.lang.RuntimeException - if this method is called before calling
the initializeProtocol(java.util.Properties) method.public java.util.Properties getDefaultProperties()
getDefaultProperties in class CommProtocolpublic int getPort()
public java.lang.String getHost()
protected void reporter(int level,
java.lang.String message)
public void sendSignal(Node node,
Signal signal)
sendSignal in class CommProtocolnode - The node the signal is sent to.signal - The siganl object to be sent.
public void signalEventExternal(Node node,
Signal signal)
public void signalEventApplication(Node node,
Signal signal)
public void signalEventGui(Node node,
com.bbn.omar.guiclient.DistOmarEvent_Gui guiEvt)
public void run()
run in interface java.lang.Runnablepublic java.util.Vector getNodes()
getNodes in class CommProtocolCapConnection objects.public Node getLocalNode()
Node object.
In the case of sockets, this is presently set to null. In theory,
this method should return a CapConnection object that represents a
connection established to the SignalServer from the same JVM.
getLocalNode in class CommProtocolNode
object.public boolean acceptConnection(CapConnection cc)
public void waitForConnection(int conns)
conns - the number of remote connections that this method
should wait for.
public CapConnection connectToNode(java.lang.String remoteHost,
int remotePort)
remoteHost - the host machine that the remote SignalServer is
is running on.remotePort - The port that the remote SignalServer is running
on.
public CapConnection connectToNode(java.lang.String remoteHost,
int remotePort,
java.lang.String name)
remoteHost - the host machine that the remote SignalServer is
is running on.remotePort - The port that the remote SignalServer is running
on.
public CapConnection connectToNode(java.lang.String remoteHost,
int remotePort,
int type)
remoteHost - the host machine that the remote SignaServer is
is running on.remotePort - The port that the remote SignalServer is running
on.type - The registration type: One of the several registration types
defined in CapConnection.
public CapConnection connectToNode(java.lang.String remoteHost,
int remotePort,
java.lang.String remoteName,
int type)
remoteHost - the host machine that the remote SignaServer is
is running on.remotePort - The port that the remote SignalServer is running
on.remoteName - A String name for the remote Nodetype - The registration type: One of the several registration types
defined in CapConnection.
public void closeAllConnections()
public void closeProtocol()
closeProtocol in class CommProtocolpublic void registerAgent(AgentID ignore)
registerAgent in class CommProtocolpublic boolean unregisterAgent(AgentID ignore)
unregisterAgent in class CommProtocolpublic void unregisterAllAgents()
unregisterAllAgents in class CommProtocolpublic AgentID findSingleAgent(AgentID template)
findSingleAgent in class CommProtocolpublic java.util.Vector findAllAgents(AgentID ignore)
findAllAgents in class CommProtocolpublic void registerFilter(Filter filter)
registerFilter in class CommProtocolfilter - The Filter object.
public void registerFilter(Filter filter,
Node node)
registerFilter in class CommProtocolfilter - The Filter object.node - The Node object to associate
the filter with. In this case the node argument should be of type
CapConnection.public void changeFilters(java.util.Vector newFilters)
changeFilters in class CommProtocolnewFilters - A Vector of new Filter Objects.
public void changeFilters(java.util.Vector newFilters,
Node n)
changeFilters in class CommProtocolnewFilters - A Vector of new Filter Objects.n - Reference to the Node object.public void shutdownHandler()
shutdownHandler in class CommProtocol
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||