コード例 #1
0
ファイル: libuv2kTransport.cs プロジェクト: dstoffels/Theia
        // server callbacks ////////////////////////////////////////////////////
        void OnLibuvServerConnected(TcpStream handle, Exception error)
        {
            // setup callbacks
            handle.onMessage = OnLibuvServerMessage;
            handle.onError   = OnLibuvServerError;
            handle.onClosed  = OnLibuvServerClosed;

            // close if errors (AFTER setting up onClosed callback!)
            if (error != null)
            {
                Debug.Log($"libuv sv: client connection failed {error}");
                handle.CloseHandle();
                return;
            }

            // assign a connectionId via UserToken.
            // this is better than using handle.InternalHandle.ToInt32() because
            // the InternalHandle isn't available in OnLibuvClosed anymore.
            handle.UserToken = nextConnectionId++;
            connections[(int)handle.UserToken] = handle;

            Debug.Log("libuv sv: client connected with connectionId=" + (int)handle.UserToken);

            // dotsnet event
            OnServerConnected.Invoke((int)handle.UserToken);
        }
コード例 #2
0
ファイル: libuv2kTransport.cs プロジェクト: dstoffels/Theia
        void OnLibuvServerError(TcpStream handle, Exception error)
        {
            Debug.Log($"libuv sv: error {error}");
            connections.Remove((int)handle.UserToken);
            handle.CloseHandle();

            // TODO invoke OnDisconnected or does OnLibuvClosed get called anyway?
        }
コード例 #3
0
ファイル: libuv2kTransport.cs プロジェクト: dstoffels/Theia
        void OnLibuvClientError(TcpStream handle, Exception error)
        {
            Debug.Log($"libuv cl: read error {error}");
            handle.CloseHandle();

            // Mirror event
            OnClientDisconnected.Invoke();
        }
コード例 #4
0
ファイル: libuv2kTransport.cs プロジェクト: dstoffels/Theia
        // client callbacks ////////////////////////////////////////////////////
        void OnLibuvClientConnected(TcpStream handle, Exception exception)
        {
            // setup callbacks
            handle.onMessage = OnLibuvClientMessage;
            handle.onError   = OnLibuvClientError;
            handle.onClosed  = OnLibuvClientClosed;

            // close if errors (AFTER setting up onClosed callback!)
            if (exception != null)
            {
                Debug.Log($"libuv cl: client error {exception}");
                handle.CloseHandle();
                return;
            }

            // Mirror event
            OnClientConnected.Invoke();

            Debug.Log($"libuv cl: client connected.");
        }
コード例 #5
0
ファイル: libuv2kTransport.cs プロジェクト: dstoffels/Theia
 public override void ClientDisconnect()
 {
     client?.CloseHandle();
     client = null;
 }