示例#1
0
 public void Close()
 {
     if (IsOpen)
     {
         webSocket.Close();
     }
 }
        /// <summary>
        /// It will initiate the closing of the connection to the server.
        /// </summary>
        public void Close()
        {
            if (State >= WebSocketStates.Closing)
            {
                return;
            }

#if !UNITY_WEBGL || UNITY_EDITOR
            if (this.State == WebSocketStates.Connecting)
            {
                if (this.InternalRequest != null)
                {
                    this.InternalRequest.Abort();
                }

                this.State = WebSocketStates.Closed;
                if (OnClosed != null)
                {
                    OnClosed(this, (ushort)WebSocketStausCodes.NoStatusCode, string.Empty);
                }
            }
            else
            {
                this.State = WebSocketStates.Closing;
                webSocket.Close();
            }
#else
            WS_Close(this.ImplementationId, 1000, "Bye!");
#endif
        }
示例#3
0
        /// <summary>
        /// It will initiate the closing of the connection to the server.
        /// </summary>
        public void Close()
        {
            if (!IsOpen)
            {
                return;
            }
#if (!UNITY_WEBGL || UNITY_EDITOR)
            webSocket.Close();
#else
            WS_Close(this.ImplementationId, 1000, "Bye!");
#endif
        }
示例#4
0
    static int Close(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                BestHTTP.WebSocket.WebSocketResponse obj = (BestHTTP.WebSocket.WebSocketResponse)ToLua.CheckObject(L, 1, typeof(BestHTTP.WebSocket.WebSocketResponse));
                obj.Close();
                return(0);
            }
            else if (count == 3)
            {
                BestHTTP.WebSocket.WebSocketResponse obj = (BestHTTP.WebSocket.WebSocketResponse)ToLua.CheckObject(L, 1, typeof(BestHTTP.WebSocket.WebSocketResponse));
                ushort arg0 = (ushort)LuaDLL.luaL_checknumber(L, 2);
                string arg1 = ToLua.CheckString(L, 3);
                obj.Close(arg0, arg1);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: BestHTTP.WebSocket.WebSocketResponse.Close"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
        public override void StartClose(UInt16 code, string message)
        {
            if (this.State == WebSocketStates.Connecting)
            {
                if (this.InternalRequest != null)
                {
                    this.InternalRequest.Abort();
                }

                this.State = WebSocketStates.Closed;
                if (this.Parent.OnClosed != null)
                {
                    this.Parent.OnClosed(this.Parent, (ushort)WebSocketStausCodes.NoStatusCode, string.Empty);
                }
            }
            else
            {
                this.State = WebSocketStates.Closing;
                webSocket.Close(code, message);
            }
        }