javascript - SignalR Variables are being Reset -
with signalr program had client call server side method. global variables weren't working correctly did quick little test , figured out global variables seemed reset every single time, wondering doing wrong , if keep variables being reset.
javascript method:
$.connection.hub.start().done(function () { $('#send').click(function () { chat.server.send(0, document.getelementbyid("name").value, document.getelementbyid("content").value);//send calls broadcastarray }); });
hub method:
int = 0; public void broadcastarray() { var hubcontext = globalhost.connectionmanager.gethubcontext<chathub>(); hubcontext.clients.all.broadcastarray(messagearr); = + 1; }
no matter how many times called method i
returned 1, how can stop variables being reset? there way in hub class or store variables in different class? i'm not quite sure how go this.
the first thing put in try/catch see if throwing error before gets line. silently throwing exception if hubcontext not getting returned properly.
secondly hub static class? without seeing how setting hub hard tell going wrong.
Comments
Post a Comment