Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to GemCarryServer. Type 'quit' to shut down.");

            mServerHost = new ServerHost();
            mServerHost.StartServer();

            string userinput = "";
            while (userinput != "quit")
            {
                userinput = Console.ReadLine();
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to GemCarryServer. Type 'quit' to shut down.");

            mServerHost = new ServerHost();
            mServerHost.StartServer();

            string userinput = "";

            while (userinput != "quit")
            {
                userinput = Console.ReadLine();
            }
        }
Ejemplo n.º 3
0
        public GamePlayer(ServerHost context, Socket socket, int bufferSize)
        {
            this.mContext = context;
            this.Socket = socket;
            mBufferSize = bufferSize;
            mMaxBufferSize = bufferSize * 2;
            mLocalBuffer = new byte[mMaxBufferSize]; //<! For now, allow max buffer storage be 2x size of max buffer

            ConnectResponse msg = new ConnectResponse{ success = true };
            DispatchMessage(msg);

            // Temporary
            JoinGameSession();
        }
Ejemplo n.º 4
0
        public GamePlayer(ServerHost context, Socket socket, int bufferSize)
        {
            this.mContext  = context;
            this.Socket    = socket;
            mBufferSize    = bufferSize;
            mMaxBufferSize = bufferSize * 2;
            mLocalBuffer   = new byte[mMaxBufferSize]; //<! For now, allow max buffer storage be 2x size of max buffer

            ConnectResponse msg = new ConnectResponse {
                success = true
            };

            DispatchMessage(msg);

            // Temporary
            JoinGameSession();
        }
Ejemplo n.º 5
0
        private SocketAsyncEventArgsPool mSocketPool; //<! Pool of reusable SocketAsyncEventArgs objects for accept, read, and write operations

        #endregion Fields

        #region Constructors

        public AsyncServer(ServerHost host, int numConnections, int receiveBufferSize)
        {
            mContext = host;
            allDone = new Mutex();

            mNumConnectedSockets = 0;
            mNumConnections = numConnections;
            mReceiveBufferSize = receiveBufferSize;

            // Allocate buffers so that the maximum number of sockets can each have one simultaneous read and write
            int totalBytes = receiveBufferSize * numConnections * opsToPreAlloc;
            mBufferManager = new BufferManager(totalBytes, receiveBufferSize);

            mSocketPool = new SocketAsyncEventArgsPool(numConnections);
            mMaxNumberAcceptedClients = new Semaphore(numConnections, numConnections);

            Init();
        }
Ejemplo n.º 6
0
        public AsyncServer(ServerHost host, int numConnections, int receiveBufferSize)
        {
            mContext = host;
            allDone  = new Mutex();

            mNumConnectedSockets = 0;
            mNumConnections      = numConnections;
            mReceiveBufferSize   = receiveBufferSize;

            // Allocate buffers so that the maximum number of sockets can each have one simultaneous read and write
            int totalBytes = receiveBufferSize * numConnections * opsToPreAlloc;

            mBufferManager = new BufferManager(totalBytes, receiveBufferSize);

            mSocketPool = new SocketAsyncEventArgsPool(numConnections);
            mMaxNumberAcceptedClients = new Semaphore(numConnections, numConnections);

            Init();
        }