Esempio 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();
            }
        }
Esempio 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();
            }
        }
Esempio 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();
        }
Esempio 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();
        }
Esempio 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();
        }
Esempio 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();
        }