Пример #1
0
        protected void OnNotification(ref WLAN_NOTIFICATION_DATA notifData, IntPtr context)
        {
            switch (notifData.notificationCode)
            {
            case (int)WLAN_HOSTED_NETWORK_NOTIFICATION_CODE.wlan_hosted_network_state_change:

                if (notifData.dataSize > 0 && notifData.dataPtr != IntPtr.Zero)
                {
                    WLAN_HOSTED_NETWORK_STATE_CHANGE pStateChange = (WLAN_HOSTED_NETWORK_STATE_CHANGE)Marshal.PtrToStructure(notifData.dataPtr, typeof(WLAN_HOSTED_NETWORK_STATE_CHANGE));

                    switch (pStateChange.NewState)
                    {
                    case WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_active:
                        this.onHostedNetworkStarted();
                        break;

                    case WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_idle:
                        if (pStateChange.OldState == WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_active)
                        {
                            this.onHostedNetworkStopped();
                        }
                        else
                        {
                            this.onHostedNetworkAvailable();
                        }
                        break;

                    case WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_unavailable:
                        if (pStateChange.OldState == WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_active)
                        {
                            this.onHostedNetworkStopped();
                        }
                        this.onHostedNetworkAvailable();
                        break;
                    }
                }

                break;

            case (int)WLAN_HOSTED_NETWORK_NOTIFICATION_CODE.wlan_hosted_network_peer_state_change:

                if (notifData.dataSize > 0 && notifData.dataPtr != IntPtr.Zero)
                {
                    WLAN_HOSTED_NETWORK_DATA_PEER_STATE_CHANGE pPeerStateChange = (WLAN_HOSTED_NETWORK_DATA_PEER_STATE_CHANGE)Marshal.PtrToStructure(notifData.dataPtr, typeof(WLAN_HOSTED_NETWORK_DATA_PEER_STATE_CHANGE));

                    if (pPeerStateChange.NewState.PeerAuthState == WLAN_HOSTED_NETWORK_PEER_AUTH_STATE.wlan_hosted_network_peer_state_authenticated)
                    {
                        // Station joined the hosted network
                        this.onStationJoin(pPeerStateChange.NewState);
                    }
                    else if (pPeerStateChange.NewState.PeerAuthState == WLAN_HOSTED_NETWORK_PEER_AUTH_STATE.wlan_hosted_network_peer_state_invalid)
                    {
                        // Station left the hosted network
                        this.onStationLeave(pPeerStateChange.NewState);
                    }
                    else
                    {
                        // Authentication state changed
                        this.onStationStateChange(pPeerStateChange.NewState);
                    }
                }

                break;

            case (int)WLAN_HOSTED_NETWORK_NOTIFICATION_CODE.wlan_hosted_network_radio_state_change:
                if (notifData.dataSize > 0 && notifData.dataPtr != IntPtr.Zero)
                {
                    //WLAN_HOSTED_NETWORK_RADIO_STATE pRadioState = (WLAN_HOSTED_NETWORK_RADIO_STATE)Marshal.PtrToStructure(notifData.dataPtr, typeof(WLAN_HOSTED_NETWORK_RADIO_STATE));
                    // Do nothing for now
                }
                //else
                //{
                //    // // Shall NOT happen
                //    // _ASSERT(FAILSE);
                //}
                break;
            }
        }
Пример #2
0
        protected void OnNotification(ref WLAN_NOTIFICATION_DATA notifData, IntPtr context)
        {
            switch (notifData.notificationCode)
            {
                case (int)WLAN_HOSTED_NETWORK_NOTIFICATION_CODE.wlan_hosted_network_state_change:

                    if (notifData.dataSize > 0 && notifData.dataPtr != IntPtr.Zero)
                    {
                        WLAN_HOSTED_NETWORK_STATE_CHANGE pStateChange = (WLAN_HOSTED_NETWORK_STATE_CHANGE)Marshal.PtrToStructure(notifData.dataPtr, typeof(WLAN_HOSTED_NETWORK_STATE_CHANGE));

                        switch (pStateChange.NewState)
                        {
                            case WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_active:
                                this.onHostedNetworkStarted();
                                break;

                            case WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_idle:
                                if (pStateChange.OldState == WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_active)
                                {
                                    this.onHostedNetworkStopped();
                                }
                                else
                                {
                                    this.onHostedNetworkAvailable();
                                }
                                break;

                            case WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_unavailable:
                                if (pStateChange.OldState == WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_active)
                                {
                                    this.onHostedNetworkStopped();
                                }
                                this.onHostedNetworkAvailable();
                                break;
                        }
                    }

                    break;

                case (int)WLAN_HOSTED_NETWORK_NOTIFICATION_CODE.wlan_hosted_network_peer_state_change:

                    if (notifData.dataSize > 0 && notifData.dataPtr != IntPtr.Zero)
                    {
                        WLAN_HOSTED_NETWORK_DATA_PEER_STATE_CHANGE pPeerStateChange = (WLAN_HOSTED_NETWORK_DATA_PEER_STATE_CHANGE)Marshal.PtrToStructure(notifData.dataPtr, typeof(WLAN_HOSTED_NETWORK_DATA_PEER_STATE_CHANGE));

                        if (pPeerStateChange.NewState.PeerAuthState == WLAN_HOSTED_NETWORK_PEER_AUTH_STATE.wlan_hosted_network_peer_state_authenticated)
                        {
                            // Station joined the hosted network
                            this.onStationJoin(pPeerStateChange.NewState);
                        }
                        else if (pPeerStateChange.NewState.PeerAuthState == WLAN_HOSTED_NETWORK_PEER_AUTH_STATE.wlan_hosted_network_peer_state_invalid)
                        {
                            // Station left the hosted network
                            this.onStationLeave(pPeerStateChange.NewState);
                        }
                        else
                        {
                            // Authentication state changed
                            this.onStationStateChange(pPeerStateChange.NewState);
                        }
                    }

                    break;

                case (int)WLAN_HOSTED_NETWORK_NOTIFICATION_CODE.wlan_hosted_network_radio_state_change:
                    if (notifData.dataSize > 0 && notifData.dataPtr != IntPtr.Zero)
                    {
                        //WLAN_HOSTED_NETWORK_RADIO_STATE pRadioState = (WLAN_HOSTED_NETWORK_RADIO_STATE)Marshal.PtrToStructure(notifData.dataPtr, typeof(WLAN_HOSTED_NETWORK_RADIO_STATE));
                        // Do nothing for now
                    }
                    //else
                    //{
                    //    // // Shall NOT happen
                    //    // _ASSERT(FAILSE);
                    //}
                    break;
            }
        }