コード例 #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
ファイル: AbstractSession.cs プロジェクト: sky365365/NtMiner
 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);
 }
コード例 #4
0
        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;
        }
コード例 #5
0
        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);
            }
        }
コード例 #8
0
 public void CloseAsync(WsCloseCode code, string reason)
 {
     base.CloseAsync(code.ToCloseStatusCode(), reason);
 }