asp.net - Reusing same connection in signalR while navigating through different pages -


i have mvc project, multiple pages.

i have long running process, updates client on progress. however, update sent single client, instead of broadcasting all.

clients.client(connectionid).sendmessage(msg); 

in layout.cshtml, how connect hub

    var serverhub = $.connection.notifier;     window.hubready = $.connection.hub.start(function () { }); 

the problem is, when navigate page, no longer receive messages signalr, because connection id has changed.

how should workaround issue, such signalr hub can still send messages single client, while client navigates page page.

you want create server mapping of users connection id's. see: signalr 1.0 beta connection factory.

you want let users persist past ondisconnected event , when connect different connection id can continue pumping data down them.

so thought process follows:

  1. page loads, signalr connection instantiated
  2. once connection started call => trycreateuser (returns user, whether existed or created).
  3. long running process starts
  4. client changes pages -> signalr connection stops
  5. new page loads, new signalr connection instantiated
  6. once connection started see if have cookie, session, or type of data representing => trycreateuser(userdata) (returns user created on last page).
  7. data continues pumping down user.

note: if take authentication approach have authenticated prior starting connection , data cannot change during lifetime of signalr connection, can created/modified while connection in disconnected state.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -