public bool JoinServer(string name, IPAddress ip) { // if already connected to another server, first disconnect if (server != null || client != null) { Disconnect(); } try { client = new TcpClient(new IPEndPoint(Ip, 0)); if (IPAddress.IsLoopback(ip)) { client.Connect(HostNetwork.GetLocalIpAddress(), Global.NetworkPort); } else { client.Connect(ip, Global.NetworkPort); } server = new RemoteServer(name, ip, client); server.DataReceived += Server_DataReceived; return(true); } catch { return(false); } }
public LocalServer(string name, GameInfo gameInfo) { Name = name; Ip = HostNetwork.GetLocalIpAddress(); GameInfo = gameInfo; }
public LocalClient() { Ip = HostNetwork.GetLocalIpAddress(); }