StompLib is a Qt library for clients communicating with the Stomp protocol. It includes the following functionality:
A communication frame is modelled in the class StompFrame.
In the StompFrameCreator class:
- Create a CONNECT frame
- Create a STOMP frame
- Create a SUBSCRIBE frame
- Create a MESSAGE frame
- Create a UNSUBSCRIBE frame
- Create a DISCONNECT frame
In the StompFrameParser class the parsing of STOMP text messages is implemented. The method responsible for this is called parseFromTextMessage. The method implements unescaping of special symbols.
The StompClient class encapsulates a QWebSocket object that communicates with the server. Various methods for communicating through the web socket as well as signals and slots are implemented.
Example usage:
m_StompClient->setUrl(server_url);
m_StompClient->connectToServer();
StompFrameCreator stompFrameCreator;
auto connectFrame = stompFrameCreator.createConnectFrame("1.2", "", "", "", 10000, 10000);
m_StompClient->sendFrame(connectFrame);
StompFrameCreator stompFrameCreator;
QString topicName = "/topic/myTopic";
auto subscribeFrame = stompFrameCreator.createSubscribeFrame(1, topicName, "auto");
m_StompClient->sendFrame(subscribeFrame);
auto publishFrame = stompFrameCreator.createSendTextFrame("/controller/address", message);
m_StompClient->sendFrame(publishFrame);
StompFrameCreator stompFrameCreator;
auto unsubscribeFrame = stompFrameCreator.createUnsubscribeFrame(1);
m_StompClient->sendFrame(unsubscribeFrame);
auto disconnectFrame = stompFrameCreator.createDisconnectFrame(1);
m_StompClient->sendFrame(disconnectFrame);
connect(m_StompClient, &StompClient::stompMessageReceived, this, &MyClass::stompReceivedSlot);