public override bool Setup() { /* * bool closed = false; * WaitingForm.BeginWait("Connecting to host...", ev => * { * while (!client.Connected) * { * try * { * client.Connect(ip, port); * } catch (SocketException se) * { * Debug.WriteLine(se.Message); * if (closed || !ConnectionFailure()) * { * break; * } * } * } * }, () => * { * closed = true; * client.Close(); * return true; * }); * * if (closed || !client.Connected) return false; */ bool result = ClientConnect.Attempt(client, ip, port); if (!result) { return(false); } socket = client.Client; socket.SendBufferSize = bufferSize; socket.ReceiveBufferSize = bufferSize; stream = client.GetStream(); stream.ReadTimeout = timeout; return(true); }
public static void Begin(string username, string ip, int port) { var client = new TcpClient(); if (!ClientConnect.Attempt(client, ip, port)) { return; } var netRoomClient = new NetRoomClient(username, client); try { netRoomClient.Setup(); } catch (Exception e) { Helper.Error("Failed to start client.", e.Message); return; } CurrentRoom = netRoomClient; }