asp.net - Broadcasting the time, through signalr hub -


i self-hosting signalr hub, using owin stuff mentioned in signalr wiki.

every 20 seconds, broadcast current time, members in 'clock' group. have method in hub, called updateclock, handles broadcast.

but, timer run, , broadcast, "smartest" way this?

the way see it, need timer in service hosts hub, , have create connection hub , invoke command. seems lot of work, little functionality. possible this, directly in hub class, don't have create connection first?

this have done, far , more simple:

var signalconnection = new hubconnection(_signalrendpoint); var hubproxy = signalconnection.createhubproxy(_signalrhubname); signalconnection.start().wait(); hubproxy.invoke(updateclock); signalconnection.stop(); 

you can context of hub , invoke client methods on own service:

while (conditiontorun) {      thread.sleep(waitforinseconds * 1000);      var context = globalhost.connectionmanager.gethubcontext<yourhubname>();      context.clients.group("clockgroupname").updateclock(datetime.utcnow); }  

this how when need broadcast server side events clients.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -