Open SatWiz opened 9 years ago
Did the sample code work? Specifically, are you able to run the "WebSocket Stomp Server" and "WebSocket STOMP Client" sample code?
That server sample code shows how a server can register a STOMP destination (named "kitchen".) The client sample code sends a STOMP message to that destination, and all clients (including the sending client) will receive the message via the onMessage stream.
Sample code work as it is but I want to extend it with a custom message reply. Is there a response.send methode which I can create my own reply function?
I see. So you are looking for a way to modify a message before forwarding to subscribed clients?
Something like this?
If so, perhaps _onSendFrame(...)
in StompRequestHandler.dart can be made public to allow for optional processing of the received message prior to forwarding to subscribers. In the server example, it would look something like:
// Create WebSocket STOMP request handler.
@server.UriPath("/stomp")
class MyWebSocketStompHandler extends server.StompRequestHandler {
MyWebSocketStompHandler() {
addDestination(new MyKitchen());
// This function can be overridden as shown here to modify the frame receive
// before sending it to subscribed clients
Future<shared.SendFrame> onSendFrame(shared.SendFrame sendFrame, WebSocketStompConnection connection) {
sendFrame.body = "Custom message";
return onSendFrame(sendFrame, connection);
}
}
}
Would that work?
I am just discovering this and get your samples running for the stomp ws. I see that the server can handle subscriptions but can't see how it is sending custom messages back to the subscriber. Is it implement already, I don't see which methode to use. Can you please give a hint or example? Thanks.