Пример #1
0
 public void Close(WsCloseCode code = WsCloseCode.Normal, string reason = null)
 {
     if (this.objectId.HasValue)
     {
         JslibInterop.WsClose(this.objectId.Value, (int)code, reason);
     }
 }
Пример #2
0
 public void CloseAsync(WsCloseCode code, string reason)
 {
     if (TryGetWsSession(out IWsSessionAdapter wsSession))
     {
         wsSession.CloseAsync(code, reason);
     }
 }
Пример #3
0
 public void CloseAsync(WsCloseCode code, string reason)
 {
     if (base.Context.WebSocket == null ||
         base.ConnectionState == WebSocketSharp.WebSocketState.Closing ||
         base.ConnectionState == WebSocketSharp.WebSocketState.Closed)
     {
         return;
     }
     base.CloseAsync(code.ToCloseStatusCode(), reason);
 }
        public AccelByteWebSocket(IWebSocket webSocket, CoroutineRunner coroutineRunner)
        {
            this.closeCodeCurrent = WsCloseCode.NotSet;

            this.webSocket       = webSocket;
            this.coroutineRunner = coroutineRunner;

            this.webSocket.OnOpen    += OnOpenReceived;
            this.webSocket.OnMessage += OnMessageReceived;
            this.webSocket.OnError   += OnErrorReceived;
            this.webSocket.OnClose   += OnCloseReceived;
        }
        private bool isReconnectable(WsCloseCode code)
        {
            switch (code)
            {
            case WsCloseCode.Abnormal:
            case WsCloseCode.ServerError:
            case WsCloseCode.ServiceRestart:
            case WsCloseCode.TryAgainLater:
            case WsCloseCode.TlsHandshakeFailure: return(true);

            default: return(false);
            }
        }
Пример #6
0
 public void CloseAsync(WsCloseCode code, string reason)
 {
     try {
         if (base.Context.WebSocket == null ||
             base.ConnectionState == WebSocketSharp.WebSocketState.Closing ||
             base.ConnectionState == WebSocketSharp.WebSocketState.Closed)
         {
             return;
         }
         base.CloseAsync(code.ToCloseStatusCode(), reason);
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
     }
 }
Пример #7
0
        public static CloseStatusCode ToCloseStatusCode(this WsCloseCode code)
        {
            switch (code)
            {
            case WsCloseCode.Normal:
                return(CloseStatusCode.Normal);

            case WsCloseCode.Away:
                return(CloseStatusCode.Away);

            case WsCloseCode.ProtocolError:
                return(CloseStatusCode.ProtocolError);

            case WsCloseCode.Abnormal:
                return(CloseStatusCode.Abnormal);

            default:
                return(CloseStatusCode.Normal);
            }
        }
 public void CloseAsync(WsCloseCode code, string reason)
 {
     base.CloseAsync(code.ToCloseStatusCode(), reason);
 }