SignalR and Hub Persistance -
i trying out signalr, , don't quite understand how call methods client in way calls same hub.
i have 2 methods in hub:
private ctldatamanager mymanager; public void startconnection() { mymanager = new ctldatamanager("test"); mymanager.updateitemevent += mymanager_updateitemevent; mymanager.connect(); } public void stopconnection() { mymanager.disconnect(); }
and in client try call them this:
var notificationhub = $.connection.notificationhub; $.connection.hub.start() .done(function (state) { $("#submit").click(function (e) { e.preventdefault(); notificationhub.server.startconnection(); return false; }); $("#stop").click(function (e) { e.preventdefault(); notificationhub.server.stopconnection(); return false; }); });
now when click on start button works fine starts , receives data too. when click stop button throws instance of object error. appears 'mymanager' null. it's new hub open. naturally need same 1 need close connection. how can that?
from understanding, server-side hub class not persisted. therefore, mymanager object created each method call client. advice declare mymanager elsewhere in application can assure 100% up-time, , have server-side hub methods communicate way.
one way verify debug constructor of hub class. notice called every client->server-side method call.
Comments
Post a Comment