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