private void OnHostedNetworkPeerStateChanged(WLAN_HOSTED_NETWORK_PEER_STATE PeerState) { switch (PeerState.PeerAuthState) { case WLAN_HOSTED_NETWORK_PEER_AUTH_STATE.wlan_hosted_network_peer_state_invalid: UpdateStationStatus(string.Empty, PeerState.PhysicalAddress.ConvertToString(), string.Empty, "Disconnected"); IPhlpapi.DeleteIPNetEntry(WlanMgr.HostedNetworkGuid, PeerState.PhysicalAddress.Reverse()); IPhlpapi.DeleteIPNetEntry(WlanMgr.HostedNetworkGuid, PeerState.PhysicalAddress); break; case WLAN_HOSTED_NETWORK_PEER_AUTH_STATE.wlan_hosted_network_peer_state_authenticated: System.Threading.Tasks.Task.Run(() => { int tries = 0; System.Net.IPAddress PeerIPAddress = System.Net.IPAddress.None; do { tries++; PeerIPAddress = IPhlpapi.ResolveIPNetEntry(WlanMgr.HostedNetworkGuid, PeerState.PhysicalAddress); Trace.WriteLine($"Try count: {tries}"); Thread.Sleep(TimeSpan.FromSeconds(1)); }while (ICSRouter.IsConnected && (PeerIPAddress.Equals(System.Net.IPAddress.None) && tries < 60)); if (!PeerIPAddress.Equals(System.Net.IPAddress.None)) { string HostName, Mac = PeerState.PhysicalAddress.ConvertToString(); try { HostName = System.Net.Dns.GetHostEntry(PeerIPAddress).HostName; } catch { HostName = string.Empty; } UpdateStationStatus(HostName, Mac, PeerIPAddress.ToString(), "Connected"); BlockConnection(PeerState.PhysicalAddress, PeerIPAddress); } }); break; } }
protected void OnStationStateChange(WLAN_HOSTED_NETWORK_PEER_STATE stationState) { if (StationStateChange != null) { StationStateChange(this, EventArgs.Empty); } }
protected void onStationJoin(WLAN_HOSTED_NETWORK_PEER_STATE stationState) { var pStation = new WlanStation(stationState); if (StationJoin != null) { StationJoin(this, EventArgs.Empty); } }
protected void onStationLeave(WLAN_HOSTED_NETWORK_PEER_STATE stationState) { this._Stations.Remove(stationState.PeerMacAddress.ConvertToString()); if (this.StationLeave != null) { this.StationLeave(this, EventArgs.Empty); } }
protected void onStationLeave(WLAN_HOSTED_NETWORK_PEER_STATE stationState) { string MACAddress = stationState.PeerMacAddress.ConvertToString(); Trace.TraceInformation("WiFi station leave {0}", MACAddress); if (this.StationLeave != null) { this.StationLeave(this, new EventStationLeave(MACAddress)); } }
protected void onStationJoin(WLAN_HOSTED_NETWORK_PEER_STATE stationState) { var pStation = new WiFiStation(stationState); Trace.TraceInformation("WiFi station join {0}", pStation.MacAddress); if (this.StationJoin != null) { this.StationJoin(this, new EventStationJoin(pStation)); } }
protected void OnStationJoin(WLAN_HOSTED_NETWORK_PEER_STATE stationState) { var pStation = new WlanStation(stationState); _stations[pStation.MacAddress] = pStation; if (StationJoin != null) { StationJoin(this, EventArgs.Empty); } }
public WlanStation(WLAN_HOSTED_NETWORK_PEER_STATE state) { this.State = state; }
public WlanStation(WLAN_HOSTED_NETWORK_PEER_STATE state) { this.State = state; }
protected void OnStationLeave(WLAN_HOSTED_NETWORK_PEER_STATE stationState) { _stations.Remove(stationState.PeerMacAddress.ConvertToString()); RaiseStationLeave(); }