Пример #1
0
 public void Close(TClientProfile profile)
 {
     if (profile.State == ConnectionState.Connected)
     {
         client.Close(profile.Guid);
     }
 }
        async void client_NewAvailableProfile(object sender, TClientProfile newProfile)
        {
            await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                if (available.Contains(newProfile))
                {
                    return;
                }

                TClientProfile existedProfile = (TClientProfile)saved.Find((profile) => profile.Equals(newProfile));
                if (existedProfile == null)
                {
                    existedProfile = (TClientProfile)connected.Find((profile) => profile.Equals(newProfile));
                }

                if (existedProfile != null)
                {
                    existedProfile.CopyInformation(newProfile);
                    available.Add(existedProfile);
                }
                else
                {
                    available.Add(newProfile);
                }
            });
        }
Пример #3
0
        public void CopyData(IProfile copy)
        {
            TClientProfile profile = (TClientProfile)copy;

            LastIPAddress = profile.LastIPAddress;
            SetNetworkData(profile.server);
        }
Пример #4
0
        public void CopyInformation(IProfile copy)
        {
            TClientProfile profile = (TClientProfile)copy;

            Name          = profile.Name;
            LastIPAddress = profile.LastIPAddress;
        }
Пример #5
0
        public async Task ConnectAsync(TClientProfile profile)
        {
            if (profile.State == ConnectionState.Connected)
            {
                return;
            }

            await ConnectAsync(profile.LastIPAddress);
        }
Пример #6
0
        public async Task ConnectAsync(string ip)
        {
            await CancelScanningAsync();

            Guid guid = await client.ConnectAsync(new HostName(ip), SHUB_PORT);

            // Connection timeout
            if (guid == default(Guid))
            {
                if (ConnectionTimeout != null)
                {
                    ConnectionTimeout(this, ip);
                }
                return;
            }

            if (NewProfile != null)
            {
                HServerInformation serverInf = client.GetServer(guid);
                TClientProfile     profile   = new TClientProfile(serverInf, serverInf.IP);
                profile.State = ConnectionState.Connected;
                NewProfile(this, profile);
            }
        }
 void client_NewProfile(object sender, TClientProfile e)
 {
     NewProfile(e);
 }