Beispiel #1
0
        public static RemoteDeviceInfo GetLocalDeviceInfo()
        {
            RemoteDeviceInfo deviceInfo = new RemoteDeviceInfo();

            deviceInfo.appName     = Application.productName;
            deviceInfo.appVersion  = Application.version;
            deviceInfo.deviceModel = SystemInfo.deviceModel;
            deviceInfo.deviceName  = SystemInfo.deviceName;
            deviceInfo.platform    = Application.platform;

            return(deviceInfo);
        }
Beispiel #2
0
 public override bool Equals(object obj)
 {
     if (obj is RemoteDeviceInfo)
     {
         RemoteDeviceInfo other = (RemoteDeviceInfo)obj;
         if (appName == other.appName &&
             appVersion == other.appVersion &&
             deviceName == other.deviceName &&
             deviceModel == other.deviceModel &&
             platform == other.platform)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #3
0
        // Update is called once per frame
        public void Update(float deltaTime)
        {
            foreach (var client in uDPDiscoverClients)
            {
                UDPPackData uDPPackData;
                if (client.GetMessage(out uDPPackData))
                {
                    RemoteDeviceInfo deviceInfo = null;
                    deviceInfo = SimpleJsonUtils.FromJson <RemoteDeviceInfo>(uDPPackData.data);

                    Add(deviceInfo, uDPPackData.iPEndPoint);
                }
            }

            if (discoverPeerTimeoutDic.Count > 0)
            {
                foreach (var item in discoverPeerTimeoutDic.Values)
                {
                    if (item.timeOut <= 0)
                    {
                        discoverPeerRemoveList.Add(item);
                    }
                    else
                    {
                        item.timeOut -= deltaTime;
                    }
                }

                foreach (var item in discoverPeerRemoveList)
                {
                    discoverPeerTimeoutDic.Remove(item.info);
                    if (OnServerLoseFind != null)
                    {
                        OnServerLoseFind(item);
                    }
                }
                discoverPeerRemoveList.Clear();
            }
        }
Beispiel #4
0
        private void Add(RemoteDeviceInfo deviceInfo, IPEndPoint remoteEndPoint)
        {
            string ipPortString = remoteEndPoint.ToString();

            //Debug.Log("ipPortString:" + ipPortString);
            if (discoverPeerTimeoutDic.ContainsKey(deviceInfo))
            {
                RemoteTagetInfo info = discoverPeerTimeoutDic[deviceInfo];
                info.timeOut = timeOut;
                if (remoteEndPoint.AddressFamily == AddressFamily.InterNetwork)
                {
                    info.address = remoteEndPoint.Address;
                }
                else
                {
                    info.addressV6 = remoteEndPoint.Address;
                }
            }
            else
            {
                RemoteTagetInfo info = new RemoteTagetInfo(deviceInfo);
                if (remoteEndPoint.AddressFamily == AddressFamily.InterNetwork)
                {
                    info.address = remoteEndPoint.Address;
                }
                else
                {
                    info.addressV6 = remoteEndPoint.Address;
                }
                info.port    = remoteEndPoint.Port;
                info.timeOut = timeOut;
                discoverPeerTimeoutDic.Add(deviceInfo, info);

                if (OnServerDiscover != null)
                {
                    OnServerDiscover(info);
                }
            }
        }
Beispiel #5
0
 public RemoteTagetInfo(RemoteDeviceInfo info)
 {
     this.info = info;
     //this.endPoint = endPoint;
 }