Websocket sharp , reading server variable from onmessage

206 Views Asked by At

Hello I am new on web sockets so was wondering what am I doing wrong here, I have a server and client

code looks something like this

public class SampleSocketService: WebSocketBehavior
{
     private int globalvar = 1;
     protected override void OnMessage(MessageEventArgs e)
     {
         if(...somecondition)
         { 
            while(...loopcondition)
               globalvar++;
         }
         if(...anothercondition)
         { 
            this.Send(globalvar);
         }
     }
}

problem is when I am sending to client the globalvar it is always = 1

Any ideas?

0

There are 0 best solutions below