Class CMEvent
- Direct Known Subclasses:
CMConcurrencyEvent
,CMConsistencyEvent
,CMDataEvent
,CMDummyEvent
,CMFileEvent
,CMFileSyncEvent
,CMInterestEvent
,CMMqttEvent
,CMMultiServerEvent
,CMSessionEvent
,CMSNSEvent
,CMUserEvent
The CMEvent class is the superclass of every CM event. The CMEvent class includes the common header fields of a CM event such as sender, receiver, which session and group (handler session and group names) should handle this event and which session and group members (distribution session and group names) this event should be forwarded to.
CM nodes (a client or a server) communicate with each other by exchanging CM events.
CM application can send and receive a CM event through event-transmission methods
of the CM stub module (CMStub
).
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCMEvent()
Creates an empty CMEvent object.CMEvent
(ByteBuffer msg) Creates a CMEvent object. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
allocate()
boolean
protected int
Returns a target group to which the server forwards this event.Returns a target session to which the server forwards this event.Returns a group name for handling this event.Returns a session name for handling this event.int
getID()
Returns the event ID.protected int
Returns the receiver name.Returns the sender name.protected String
marshall()
Marshals the CM event.protected abstract void
protected void
protected void
putInt2BytesToByteBuffer
(int num) protected void
protected void
setByteNum
(int nByteNum) void
setDistributionGroup
(String gName) Sets a group to which this event will be forwarded by the server.void
setDistributionSession
(String sName) Sets a session to which this event will be forwarded by the server.void
setHandlerGroup
(String gName) Sets a group for handling this event.void
setHandlerSession
(String sName) Sets a session for handling this event.void
setID
(int id) Sets the event ID field.void
setReceiver
(String strName) Sets the receiver name.void
Sets the sender name.toString()
unmarshall
(ByteBuffer msg) Unmarshals the given ByteBuffer to the CM event.protected abstract void
unmarshallBody
(ByteBuffer msg) protected void
-
Field Details
-
m_strSender
-
m_strReceiver
-
m_strHandlerSession
-
m_strHandlerGroup
-
m_strDistributionSession
-
m_strDistributionGroup
-
m_nID
protected int m_nID -
m_nByteNum
protected int m_nByteNum -
m_bytes
-
-
Constructor Details
-
CMEvent
public CMEvent()Creates an empty CMEvent object. -
CMEvent
Creates a CMEvent object.
This CM object marshalls a given bytes of a message.- Parameters:
msg
- - the bytes of a message
-
-
Method Details
-
marshall
Marshals the CM event.
This method changes the event fields into bytes in the ByteBuffer so that the event can be sent through the communication channel.
If the subclass of the CMEvent class is instantiated and the object calls this method, it conducts marshalling of both the event header and the event body fields.- Returns:
- a reference to the ByteBuffer object that includes the marshalled event fields. If the instance of the subclass of the CMEvent calls this method, the ByteBuffer object includes both the marshalled event header and body fields.
-
unmarshall
Unmarshals the given ByteBuffer to the CM event.
This method changes bytes in the ByteBuffer to the corresponding event fields of this event object.
If the subclass of the CMEvent class is instantiated and the object calls this method, it conducts unmarshalling of both the event header and the event body fields.- Parameters:
msg
- - the bytes to be unmarshalled- Returns:
- a reference to the CMEvent object.
-
setID
public void setID(int id) Sets the event ID field.
When the event object is initialized, the event ID is set to -1.- Parameters:
id
- - the event ID
-
getID
public int getID()Returns the event ID.- Returns:
- an event ID, or -1 if this event does not set any ID.
-
setSender
Sets the sender name.- Parameters:
strName
- - the sender name
-
getSender
Returns the sender name.- Returns:
- a sender name.
-
setReceiver
Sets the receiver name.- Parameters:
strName
- - the receiver name.
-
getReceiver
Returns the receiver name.- Returns:
- a receiver name.
-
setHandlerSession
Sets a session for handling this event.
The session name determines which session deals with this event.
When the event object is initialized, the session for handling this event is set to the empty string (""). The empty session name specifies that this event is internally handled by the CMInteractionManager of the receiver CM.- Parameters:
sName
- - the session name
-
setHandlerGroup
Sets a group for handling this event.
The group name determines which group deals with this event.
When the event object is initialized, the group for handling this event is set to the empty string (""). If the group name is empty and the specific session name is set, this event is internally handled by the CMSessionManager of the receiver CM. If both the group and the session are empty, this event is internally handled by the CMInteractionManager of the receiver CM. If both the group and the session are set to specific names, this event is internally handled by the CMGroupManager of the receiver CM.- Parameters:
gName
- - the group name
-
setDistributionSession
Sets a session to which this event will be forwarded by the server.
The session name determines to which session the server will forward this event after it receives and processes this event. Normally, session and group for the distribution of the event are determined by CM when the client callsCMStub.send(CMEvent, String)
,CMStub.cast(CMEvent, String, String)
, orCMStub.broadcast(CMEvent)
methods.When the event object is initialized, the session for distribution is set to the empty string (""). If the session name is empty, the server does not forward this event. If the session is set to a specific name, the distribution target is determined by the group name for the distribution. If the session name is "CM_ALL_SESSION", the server forwards this event to members of all sessions and groups. If the session name is "CM_ONE_USER", the distribution target is one user whose name should be set in the group name for the distribution.
- Parameters:
sName
- - the session name for the distribution of this event.
The sName value can be a session name, "CM_ALL_SESSION", or "CM_ONE_USER".- See Also:
-
setDistributionGroup
Sets a group to which this event will be forwarded by the server.
The group name determines to which group the server will forward this event after it receives and processes this event. Normally, session and group for the distribution of the event are determined by CM when the client callsCMStub.send(CMEvent, String)
,CMStub.cast(CMEvent, String, String)
, orCMStub.broadcast(CMEvent)
methods.When the event object is initialized, the group for distribution is set to the empty string (""). If the group name is empty, the server does not forward this event. If the group is set to a specific name, the server forwards this event to the corresponding group members. If the group name is CM_ALL_GROUP", the server forwards this event to members of all groups. If the group name is a specific user name (and if the session name is "CM_ONE_USER"), the server forwards this event to the corresponding specific user.
- Parameters:
gName
- - the group name for the distribution of this event.
The gName value can be a group name, "CM_ALL_GROUP", or a specific user name.- See Also:
-
getHandlerSession
Returns a session name for handling this event.
The session name determines which session deals with this event.- Returns:
- - a session name for handling this event.
- See Also:
-
getHandlerGroup
Returns a group name for handling this event.
The group name determines which group deals with this event.- Returns:
- - a group name for handling this event.
- See Also:
-
getDistributionSession
Returns a target session to which the server forwards this event.
The session name determines to which session the server will forward this event after it receives and processes this event.- Returns:
- - a session name for distributing this event.
- See Also:
-
getDistributionGroup
Returns a target group to which the server forwards this event.
The group name determines to which group the server will forward this event after it receives and processes this event.- Returns:
- - a group name for distributing this event.
- See Also:
-
equals
-
toString
-
allocate
protected boolean allocate() -
marshallHeader
protected void marshallHeader() -
unmarshallHeader
-
marshallBody
protected abstract void marshallBody() -
unmarshallBody
-
setByteNum
protected void setByteNum(int nByteNum) -
getByteNum
protected int getByteNum() -
putStringToByteBuffer
-
getStringFromByteBuffer
-
putInt2BytesToByteBuffer
protected void putInt2BytesToByteBuffer(int num) -
getInt2BytesFromByteBuffer
-