Package cmion.level2
Class RemoteTCPCompetency
java.lang.Object
ion.Meta.Element
cmion.architecture.CmionComponent
cmion.level2.Competency
cmion.level2.RemoteCompetency
cmion.level2.RemoteTCPCompetency
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
ExampleTCPCompetency
A class encapsulating tcp communication with another process on the network.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intthe port on which to establish the tcp connectionFields inherited from class cmion.level2.Competency
available, competencyName, competencyType, plan, runningFields inherited from class cmion.architecture.CmionComponent
architecture -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRemoteTCPCompetency(IArchitecture architecture, int port, boolean serverMode, String serverAddress) create a new remote TCP competency -
Method Summary
Modifier and TypeMethodDescriptionfinal voidinitialises the tcp connectionprotected final voidsendMessage(String message) use this method to send a message to the remotely connected competency.Methods inherited from class cmion.level2.RemoteCompetency
competencyCode, processMessage, returnFailure, returnSuccess, startExecutionMethods inherited from class cmion.level2.Competency
cancel, getCompetencyName, getCompetencyType, isAvailable, isRunning, registerHandlers, requestStartCompetency, run, runsInBackground, setAdditionalDataMethods inherited from class cmion.architecture.CmionComponent
getArchitecture, isConnected, onDestroy, raiseMethods inherited from class ion.Meta.Element
destroy, getEventFilters, getEventHandlers, getRequestFilters, getRequestHandlers, getSimulation, getUID, schedule, wasDestroyed
-
Field Details
-
port
protected int portthe port on which to establish the tcp connection
-
-
Constructor Details
-
RemoteTCPCompetency
protected RemoteTCPCompetency(IArchitecture architecture, int port, boolean serverMode, String serverAddress) create a new remote TCP competency- Parameters:
architecture- a reference to the architecture objectport- the port on which we want to establish a connectionserverMode- if true, we act as a server and listen for a remote program to connect, if false, we assume the role of a client and connect to a server on the networkserverAddress- if serverMode is false this tells us the server address we have to connect to, if serverMode is true this parameter is not used (can be null)
-
-
Method Details
-
initialize
public final void initialize()initialises the tcp connection- Specified by:
initializein classCompetency
-
sendMessage
use this method to send a message to the remotely connected competency. Call it typically from the startExecution method or from an event handler- Specified by:
sendMessagein classRemoteCompetency
-