示例#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();
                    }
                }
            }
        }
示例#2
0
 public void TriggerOnError(string error)
 {
     this.State = GameSparksWebSocketState.Closed;
     if (errorCallback != null)
     {
         errorCallback(error);
     }
 }
示例#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();
            }
        }
示例#7
0
        public void TriggerOnClose()
        {
            this.State = GameSparksWebSocketState.Closed;

            this.controller.RemoveWebSocket(this);

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

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

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

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

            this.controller.RemoveWebSocket(this);

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