Esempio n. 1
0
        internal void EnsureConnected()
        {
            if (_stopped)
            {
                return;
            }

            if (!GameSparksUtil.ShouldConnect)
            {
                return;
            }

            lock (this) {
                if (_WebSocketClient == null)
                {
                    _WebSocketClient = _gSPlatform.GetSocket(url, GSConnection_OnMessageReceived, OnClosed, OnOpened, OnError);
                }

                lock (_WebSocketClient)
                {
                    GameSparksWebSocketState state = _WebSocketClient.State;

                    if (mustConnectBy < DateTime.Now.Ticks && state == GameSparksWebSocketState.Connecting)
                    {
                        Terminate();
                    }
                    else if (state != GameSparksWebSocketState.Open && state != GameSparksWebSocketState.Connecting)
                    {
                        _WebSocketClient.Open();
                    }
                }
            }
        }
Esempio n. 2
0
 public void TriggerOnError(string error)
 {
     this.State = GameSparksWebSocketState.Closed;
     if (errorCallback != null)
     {
         errorCallback(error);
     }
 }
Esempio n. 3
0
 public void TriggerOnOpen()
 {
     this.State = GameSparksWebSocketState.Open;
     if (openCallback != null)
     {
         openCallback();
     }
 }
        public void TriggerOnError(string message)
        {
            State = GameSparksWebSocketState.Closed;

            if (onError != null)
            {
                onError(message);
            }
        }
        public void TriggerOnOpen()
        {
            State = GameSparksWebSocketState.Open;

            if (onOpen != null)
            {
                onOpen();
            }
        }
        public void TriggerOnClose()
        {
            State = GameSparksWebSocketState.Closed;
            controller.RemoveWebSocket(this);

            if (onClose != null)
            {
                onClose();
            }
        }
Esempio n. 7
0
        public void TriggerOnClose()
        {
            this.State = GameSparksWebSocketState.Closed;

            this.controller.RemoveWebSocket(this);

            if (closeCallback != null)
            {
                closeCallback();
            }
        }
Esempio n. 8
0
        public void TriggerOnClose()
        {
            State = GameSparksWebSocketState.Closed;
            controller.RemoveWebSocket(this);

            if (onClose != null)
                onClose();
        }
Esempio n. 9
0
 public void Open()
 {
     State = GameSparksWebSocketState.Connecting;
     GSExternalOpen(SocketId, url, controllerName);
 }
Esempio n. 10
0
 public void TriggerOnOpen()
 {
     this.State = GameSparksWebSocketState.Open;
     if(openCallback != null)
         openCallback();
 }
Esempio n. 11
0
        public void TriggerOnOpen()
        {
            State = GameSparksWebSocketState.Open;

            if (onOpen != null)
                onOpen();
        }
Esempio n. 12
0
        public void TriggerOnError(string message)
        {
            State = GameSparksWebSocketState.Closed;

            if (onError != null)
                onError(message);
        }
Esempio n. 13
0
        public void TriggerOnClose()
        {
            this.State = GameSparksWebSocketState.Closed;

            this.controller.RemoveWebSocket(this);

            if(closeCallback != null)
                closeCallback();
        }
Esempio n. 14
0
 public void Open()
 {
     this.State = GameSparksWebSocketState.Connecting;
     GSSocketOpen(this.SocketId, url);
 }
Esempio n. 15
0
 public void Close()
 {
     this.State = GameSparksWebSocketState.Closing;
     GSSocketClose(this.SocketId);
 }
Esempio n. 16
0
 public void Close()
 {
     State = GameSparksWebSocketState.Closing;
     GSExternalClose(SocketId);
 }
Esempio n. 17
0
 public void TriggerOnError(string error)
 {
     this.State = GameSparksWebSocketState.Closed;
     if(errorCallback != null)
         errorCallback(error);
 }