c# - First arbitrary messages in signalR has no messageID? -
i wrote simple code --when connected , should yield
- "first !"
- "welcome"
- 3 messages ( timer)
this code :
int = 0; protected override task onconnected(irequest request, string connectionid) { //first message connection.send(connectionid, "first !"); //first message //last messages timer _timer = new timer(runme, new {con = connectionid, req = request}, 2000, 1000); //second message return connection.send(connectionid, "welcome!"); //second message } void runme(dynamic state) { if (i < 3) { connection.send((string) state.con, "loop " + i); i++; } }
and here js code ( inside document.ready
block) :
...
connection.received(function (data) { $('#messages').append('<li><b>data received = </b>' + data + "<b>connectionid =</b> " + connection.id + '<b>messageid = </b>' + connection.messageid + '</li>'); });
i responses.
but if press f5(refresh) -- these typical responses :
refresh again ,
it seems first message never gets messageid
:
and later messages sometimes messageid , sometimes not.
ps
i thought myself , maybe it's initialization speed problems , tried :
and again , response :
- what's going on here ? why first messages doesn't messageid ? how can fix ?
in signalr 1.1, connection.messageid set after of connection.received handlers have been called batch of messages.
message ids meant used signalr internally, in signalr 2.0 connection.messageid set before connection.received handlers called.
Comments
Post a Comment