Socket messages with data not being received
hmmdeif opened this issue · comments
In the two socket
classes the message controller is added with the message name and data (stringified) together instead of just the message name. This needs to change to so that it only enters the message from:
_ws.onMessage.listen((e) {
var msg = new Message(e.data);
_messageController.add(msg);
});
To:
_ws.onMessage.listen((e) {
var msg = new Message.fromPacket(e.data);
_messageController.add(msg.name);
});
I think that would work, but you should get what I'm on about. I don't know how I would add a unit test to test this however.
I agree with you. A updated it in my code.
This way you won't get any data from your messages.
Why ? with the correction ("new Message.fromPacket(e.data)") it works well.
_messageController.add(msg.name);
this won't work, atream needs an object.
- Now data is just an
optional argument
, notnamed optional
, so you can just send it likesend(message, data)
- You won't get anything except the data itself in the listener, so
socket.on('ping').listen((data) {})
will get onlydata
itself, not the whole message
Yup, you're correct - I thought I would have missed something. Thanks! :)