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 TypeMethodDescriptionintvoidhandleIncomingMessage(Ipmiv20Message message) Checks if received message is inside "sliding window range", and if it is, further processes the message in a cimplementation-specific way.intretryMessage(int tag, StateMachine stateMachine, int sessionId) Attempts to retry sending message with given tag, assuming that this message exists in message queue.intsendMessage(PayloadCoder payloadCoder, StateMachine stateMachine, int sessionId, boolean isOneWay) Attempts to send message encoded by givenPayloadCoderto the remote system.voidsetTimeout(int timeout) voidtearDown()
-
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 givenPayloadCoderto the remote system.- Parameters:
payloadCoder- instance ofPayloadCoderthat will produce payload for the message being sent.stateMachine-StateMachinefor 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-StateMachinefor 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()
-