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); } }); }
public void CopyData(IProfile copy) { TClientProfile profile = (TClientProfile)copy; LastIPAddress = profile.LastIPAddress; SetNetworkData(profile.server); }
public void CopyInformation(IProfile copy) { TClientProfile profile = (TClientProfile)copy; Name = profile.Name; LastIPAddress = profile.LastIPAddress; }
public async Task ConnectAsync(TClientProfile profile) { if (profile.State == ConnectionState.Connected) { return; } await ConnectAsync(profile.LastIPAddress); }
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); }