Esempio n. 1
0
        public virtual bool GetIPList()
        {
            byte[]    ipASync;
            IPAddress ipAS;
            NetConn   xConn;
            string    sPathASync = @"HKEY_LOCAL_MACHINE\Comm\Tcpip\Hosts\ppp_peer";

            m_Connected = false;

            ipASync = (byte[])Registry.GetValue(sPathASync, "ipaddr", new byte[] { });
            if ((ipASync != null) && (ipASync.Length == 4))
            {// ASync present
                ipAS = new System.Net.IPAddress(ipASync);
            }
            else
            {
                ipAS = null;
            }

            xNetConn = new List <NetConn>();
            System.Net.IPHostEntry ipList = System.Net.Dns.GetHostEntry(sHost);
            foreach (System.Net.IPAddress ip in ipList.AddressList)
            {
                if (System.Net.IPAddress.IsLoopback(ip) == false)
                {
                    m_Connected  = true;
                    xConn        = new NetConn();
                    xConn.IPAddr = ip.ToString();
                    if (ipAS != null)
                    {
                        xConn.TConn = CONN_TYPE.ACTIVESYNC;
                        byte[] bA = ip.GetAddressBytes();
                        for (int i = 0; i < 3; i++)
                        {
                            if (bA[i] != ipASync[i])
                            {
                                xConn.TConn = CONN_TYPE.NOCONNECTIONS;
                                break;
                            }
                        }
                    }
                    if (xConn.TConn == CONN_TYPE.NOCONNECTIONS)
                    {// это не ActiveSync
                        xConn.TConn = CONN_TYPE.WIFI;
                    }
                    xNetConn.Add(xConn);
                }
            }
            if (m_Connected)
            {
                sIP = xNetConn[0].IPAddr;
            }
            else
            {
                sIP = "";
            }
            return(m_Connected);
        }
Esempio n. 2
0
    private void SendFileToClients(NetworkMessage netMsg)
    {
        NetConn msg = netMsg.ReadMessage <NetConn>();

        foreach (var addr in msg.addresses)
        {
            InvokeThread(addr, msg.port, msg.file);
        }
    }
Esempio n. 3
0
 public void becomeClient()
 {
     connectionsPanel.SetActive(false);
     nc = new NetConn(pw, onConnectCB, "localhost", 12345, mode.CLIENT);
     hostStatus.gameObject.SetActive(true);
     hostStatus.text = "Attempting to connect...";
     isHost          = false;
     playerType      = pieceType.OPIECE;
     enemyType       = pieceType.XPIECE;
 }
Esempio n. 4
0
 public void becomeHost()
 {
     connectionsPanel.SetActive(false);
     nc = new NetConn(pw, onConnectCB, "localhost", 12345, mode.HOST);
     hostStatus.gameObject.SetActive(true);
     hostStatus.text = "Waiting for connection...";
     isHost          = true;
     playerType      = pieceType.XPIECE;
     enemyType       = pieceType.OPIECE;
 }
Esempio n. 5
0
    private void ServerConnections(NetworkMessage netMsg)
    {
        NetConn       msg       = netMsg.ReadMessage <NetConn>();
        List <string> addresses = new List <string>();

        foreach (var conn in NetworkServer.connections)
        {
            if (conn != null)
            {
                addresses.Add(conn.address);
            }
        }
        msg.addresses = addresses.ToArray();

        NetworkServer.SendToClient(netMsg.conn.connectionId, getClientsSendFile, msg);
    }
Esempio n. 6
0
 public void setClient()
 {
     Debug.Log("Setting as client!");
     NetConn test = new NetConn(pw, "localhost", 33, mode.CLIENT);
 }
Esempio n. 7
0
 /// <summary>
 /// Setup a connection as a host
 /// </summary>
 public void setHost()
 {
     Debug.Log("Setting as host!");
     NetConn test = new NetConn(pw, "localhost", 33, mode.HOST);
 }