Ejemplo n.º 1
0
        public static bool onConnect(Socket socket)
        {
            if (!mActive)
            {
                return(false);
            }

            lock (mConnectionList.SyncRoot)
            {
                if (mConnectionList.Count >= cMaxConnections)
                {
                    return(false);
                }

                DebugConnection connection = new DebugConnection(mTextCallback, mConnectionList.Count);
                if (!connection.connect(socket))
                {
                    return(false);
                }

                if (!mActive)
                {
                    return(false);
                }

                mConnectionList.Add(connection);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public static void removeConnection(DebugConnection c)
        {
            lock (mConnectionList.SyncRoot)
            {
                int i = mConnectionList.IndexOf(c);
                if (i > 0)
                {
                    mTextCallback("<debug>Deleting debug connection [" + c.getID().ToString() + "]</debug>");

                    mConnectionList.RemoveAt(i);
                }
            }
        }
Ejemplo n.º 3
0
        public static void helperThread(object parameter)
        {
            DebugConnection connection = (DebugConnection)parameter;

            connection.mRecvBufferLen = 0;

            connection.mSocket.BeginReceive(connection.mRecvBuffer, 0, connection.mRecvBuffer.Length, 0, new AsyncCallback(ReadCallBack), connection);

            for ( ; ;)
            {
                try
                {
                    WaitHandle[] waitHandles     = { connection.mExitThread, connection.mCommandReady };
                    int          waitHandleIndex = WaitHandle.WaitAny(waitHandles);

                    if (waitHandleIndex == 0)
                    {
                        break;
                    }

                    connection.sendQueuedCommands();
                }
                catch
                {
                    break;
                }
            }

            connection.mSocket.Close();

            if (connection.mTextCallback != null)
            {
                connection.mTextCallback("<debug>Debug connection [" + connection.mID.ToString() + "] disconnected: " + connection.getXboxName() + " (" + connection.getIP() + ") </debug>");
            }

            DebugConnectionManager.removeConnection(connection);
        }
Ejemplo n.º 4
0
        private static void ReadCallBack(IAsyncResult ar)
        {
            DebugConnection connection = (DebugConnection)ar.AsyncState;

            connection.processReadCallBack(ar);
        }