Class MessageHandler
java.lang.Object
org.metricshub.ipmi.core.connection.MessageHandler
- Direct Known Subclasses:
IpmiMessageHandler
,SolMessageHandler
Class used for handling outgoing and incoming messages for a
Connection
.-
Constructor Summary
ConstructorsConstructorDescriptionMessageHandler
(Connection connection, int timeout, int minSequenceNumber, int maxSequenceNumber) -
Method Summary
Modifier and TypeMethodDescriptionint
void
handleIncomingMessage
(Ipmiv20Message message) Checks if received message is inside "sliding window range", and if it is, further processes the message in a cimplementation-specific way.int
retryMessage
(int tag, StateMachine stateMachine, int sessionId) Attempts to retry sending message with given tag, assuming that this message exists in message queue.int
sendMessage
(PayloadCoder payloadCoder, StateMachine stateMachine, int sessionId, boolean isOneWay) Attempts to send message encoded by givenPayloadCoder
to the remote system.void
setTimeout
(int timeout) void
tearDown()
-
Constructor Details
-
MessageHandler
public MessageHandler(Connection connection, int timeout, int minSequenceNumber, int maxSequenceNumber)
-
-
Method Details
-
sendMessage
public int sendMessage(PayloadCoder payloadCoder, StateMachine stateMachine, int sessionId, boolean isOneWay) throws ConnectionException Attempts to send message encoded by givenPayloadCoder
to the remote system.- Parameters:
payloadCoder
- instance ofPayloadCoder
that will produce payload for the message being sent.stateMachine
-StateMachine
for the currenr connection.sessionId
- ID of the current session.isOneWay
- flag indicating, if message is one way and we shouldn't await response, or it isn't and needs response from remote system- Returns:
- sequence number of the sent message
- Throws:
ConnectionException
- when could not send message due to some problems with connection
-
retryMessage
public int retryMessage(int tag, StateMachine stateMachine, int sessionId) throws ConnectionException Attempts to retry sending message with given tag, assuming that this message exists in message queue.- Parameters:
tag
- tag of the message that we want to resendstateMachine
-StateMachine
for the currenr connection.sessionId
- ID of the current session.- Returns:
- sequence number of the retried message (should be the same as original message tag) or -1 if no message was found in the queue.
- Throws:
ConnectionException
- when could not send message due to some problems with connection
-
handleIncomingMessage
Checks if received message is inside "sliding window range", and if it is, further processes the message in a cimplementation-specific way.- Parameters:
message
-
-
setTimeout
public void setTimeout(int timeout) -
tearDown
public void tearDown() -
getSequenceNumber
public int getSequenceNumber()
-