Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
 public LocalServer(string name, GameInfo gameInfo)
 {
     Name     = name;
     Ip       = HostNetwork.GetLocalIpAddress();
     GameInfo = gameInfo;
 }
Exemplo n.º 3
0
 public LocalClient()
 {
     Ip = HostNetwork.GetLocalIpAddress();
 }