public override void Send(string text) { Thread tSendToServer = new Thread(delegate() { try { MyNetwork.Write(client, text); } catch { ConnectionLost(); } }); tSendToServer.IsBackground = true; tSendToServer.Start(); // Echo text will be sent back by the server }
public void SendToUser(User user, string text, CallBack callBack = null) { Thread tSendToUser = new Thread(delegate() { try { MyNetwork.Write(user.socket, text); } catch { Offline(user); } if (callBack != null) { callBack(); } }); tSendToUser.IsBackground = true; tSendToUser.Start(); }
void Connect(string ip, int port) { try { client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); client.Connect(ip, port); MyNetwork.Write(client, username); //Send username } catch { ConnectionLost(); return; } EnableInput(); Thread tRAA = new Thread(delegate() { ReadAndAct(); }); tRAA.IsBackground = true; tRAA.Start(); }