/// <summary> /// Create and start the chat room server. /// </summary> /// <param name="args">Unused.</param> static void Main(string[] args) { Logger.Log(Resources.StartingServer); handler = new ServerMessageHandler(); listener = new Listener(Utilities.ConfigurationManager.GetServerPort(), handler); listener.Start(); }
/// <summary> /// Creates a new client connected on the given socket. /// </summary> /// <param name="accepted">An accepted connection that is connected to a client.</param> /// <param name="handler">The handler that will handle all message interactions.</param> public Client(TcpClient accepted, ServerMessageHandler handler) : base(accepted, handler) { // ask the user to pick a nickname int userID = handler.GenerateUserID(); User = new User(userID); User.SetNickname(ChooseNickname()); // update the client with the list of currently connected users UpdateClient(); // start to listen asyncronously active = true; thread.Start(); }
/// <summary> /// Creates a new listener for new connections to the server. /// </summary> /// <param name="port">Port that the listener will listen on.</param> /// <param name="handler">The handler that this will send new connections to.</param> public Listener(int port, ServerMessageHandler handler) { this.port = port; this.handler = handler; }