Esempio n. 1
0
    //---------------------------------------------------------------------
    public void Update(float elapsed_tm)
    {
        if (mSession != null)
        {
            mSession.Update();
        }

        while (true)
        {
            SocketEvent socket_event;
            socket_event.type   = eSocketEventType.Null;
            socket_event.client = null;
            socket_event.args   = null;

            lock (LockWorker)
            {
                if (mSocketEvent.Count > 0)
                {
                    socket_event = mSocketEvent.Dequeue();
                }
            }

            if (socket_event.type == eSocketEventType.Null)
            {
                break;
            }

            switch (socket_event.type)
            {
            case eSocketEventType.Connected:
            {
                if (OnSocketConnected != null)
                {
                    OnSocketConnected.Invoke(null, socket_event.args);
                }
            }
            break;

            case eSocketEventType.Closed:
            {
                if (OnSocketClosed != null)
                {
                    OnSocketClosed.Invoke(null, socket_event.args);
                }
            }
            break;

            case eSocketEventType.Error:
            {
                if (OnSocketError != null)
                {
                    OnSocketError.Invoke(null, (SocketErrorEventArgs)socket_event.args);
                }
            }
            break;
            }
        }
    }
Esempio n. 2
0
    //-------------------------------------------------------------------------
    void _onSocketClosed(object client, EventArgs args)
    {
        //this.tcpSocket = null;

        if (OnSocketClosed != null)
        {
            OnSocketClosed.Invoke(this, args);
        }
    }
Esempio n. 3
0
 private static void Trace(string LogText, Socket TcpSocket)
 {
     OnSocketClosed?.Invoke(LogText, TcpSocket);
     foreach (TraceListener debug in Debug.Listeners)
     {
         debug.WriteLine(LogText);
     }
     if (isConnected)
     {
         isConnected = false; Reconnect();
     }
 }
Esempio n. 4
0
    //---------------------------------------------------------------------
    public void Close()
    {
        if (mSession != null)
        {
            mSession.Dispose();
            mSession = null;

            if (OnSocketClosed != null)
            {
                OnSocketClosed.Invoke(null, EventArgs.Empty);
            }
        }
    }
Esempio n. 5
0
 public void CloseSocket()
 {
     try
     {
         try
         {
             var closeTask = m_webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing", CancellationToken.None);
         }
         catch { }
         m_webSocket = null;
         OnSocketClosed?.Invoke(this, null);
     }
     catch { }
 }
Esempio n. 6
0
 private void NotifyOnSocketClosed(string socketName) => OnSocketClosed?.Invoke(socketName);