static void Main(string[] args) { try { server = new ServerInstance(); listenThread = new Thread(() => server.Listen(8888)); listenThread.Start(); } catch (Exception ex) { server.Disconnect(); Console.WriteLine(ex.Message); } }
public ClientInstance(ITcpWrapper tcpClient, ServerInstance serverInstance, ICoding coding) { Id = Guid.NewGuid(); server = serverInstance; this.tcpClient = tcpClient; this.coding = coding; aesEncryption = new AesEncryption(); RequestHandlers = new Dictionary <ClientAction, Action <string> > { { ClientAction.Login, LoginHandler }, { ClientAction.Register, RegisterHandler }, { ClientAction.ShowAllChats, ShowAllChatsHandler }, { ClientAction.CreateChat, CreateChatHandler }, { ClientAction.EnterChat, EnterChatHandler }, { ClientAction.ShowUsersInChat, ShowUsersInChatHandler }, { ClientAction.GoToMainMenu, GoToMainMenuHandler }, { ClientAction.SendMessage, MessageHandler } }; }