lvivski / start

Sinatra inspired web development framework for Dart

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Socket messages with data not being received

hmmdeif opened this issue · comments

commented

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.

  1. Now data is just an optional argument, not named optional, so you can just send it like send(message, data)
  2. You won't get anything except the data itself in the listener, so socket.on('ping').listen((data) {}) will get only data itself, not the whole message
commented

Yup, you're correct - I thought I would have missed something. Thanks! :)