public static void initialize(WriteMessageFunc argWriteMessage, ChangeUserFunc argUserChanger) { localIP = getLocalIP(); extIP = getExtIP(); domainAddress = getDomainAddress(); chatServer = new System.Net.Sockets.TcpListener(localIP, 24658); chatServer.Start(); textBoxWriter = argWriteMessage; userChanger = argUserChanger; users = new List <Communicator>(); updateThread = new Thread(new ThreadStart(updateServer)); updateThread.IsBackground = true; updateThread.Start(); }
public Communicator(System.Net.Sockets.TcpClient connection, WriteMessageFunc messageGotten) { client = connection; writer = new StreamWriter(client.GetStream()); reader = new StreamReader(client.GetStream()); try { //This will block other people from joining. Fix. ipAddress = reader.ReadLine(); name = reader.ReadLine(); if (name == null) { name = "Unnamed user"; } } catch { name = "Unnamed user"; } textBoxWriter = messageGotten; receiveMessage = new Thread(new ThreadStart(getMessage)); receiveMessage.IsBackground = true; receiveMessage.Start(); }
public static void initialize(WriteMessageFunc argWriteMessage, ChangeUserFunc argUserChanger) { localIP = getLocalIP(); extIP = getExtIP(); domainAddress = getDomainAddress(); chatServer = new System.Net.Sockets.TcpListener(localIP, 24658); chatServer.Start(); textBoxWriter = argWriteMessage; userChanger = argUserChanger; users = new List<Communicator>(); updateThread = new Thread(new ThreadStart(updateServer)); updateThread.IsBackground = true; updateThread.Start(); }