示例#1
0
        public static void HandleLinkDown(Wlan.WlanNotificationData notifyData)
        {
            NativeWifi.WlanClient.WlanInterface wlanIface = null;// = GenericInfo.WlanInterface;
            foreach (NativeWifi.WlanClient.WlanInterface wli in Information.GenericInfo.ClientInstance.Interfaces)
            {
                if (wli.InterfaceGuid == notifyData.interfaceGuid)
                {
                    if (wli.NetworkInterface.GetPhysicalAddress().Equals(PhysicalAddress.Parse(Program.MAC.Replace(":", "-").ToUpper()))) //Event filtering
                    {
                        wlanIface = wli;
                    }
                }
            }

            if (wlanIface != null)
            {
                ConnectionHelper ch = Program.toMihf;
                ID myLinkID         = new ID(new OctetString(GenericInfo.myID));
                ID mihfID           = new ID(new OctetString(GenericInfo.mihfID));

                if (Subscriptions.List.Link_Down)
                {
                    ch.Send(MessageBuilders.Link_Down_Indication_802_11_MsgBuilder(myLinkID, mihfID,
                                                                                   new String(Encoding.ASCII.GetChars(wlanIface.LatestConnection.wlanAssociationAttributes.dot11Ssid.SSID)),
                                                                                   wlanIface.LatestConnection.wlanAssociationAttributes.Dot11Bssid,
                                                                                   Link_Dn_Reason.ExplicitDisconnect).ByteValue);//TODO get reasons
                }
            }
        }
    public void SendReturnMessage()
    {
        string messageToSend = MessageBuilders.BuildLobbyMessage();

        m_cooldownTimer = m_cooldownAfterSwitch;
        TCPClient.SendMessage(messageToSend);
    }
示例#3
0
        public static void HandleParamsReport(Wlan.WlanNotificationData notifyData)
        {
            NativeWifi.WlanClient.WlanInterface wlanIface = null;// = GenericInfo.WlanInterface;
            foreach (NativeWifi.WlanClient.WlanInterface wli in Information.GenericInfo.ClientInstance.Interfaces)
            {
                if (wli.InterfaceGuid == notifyData.interfaceGuid)
                {
                    if (wli.NetworkInterface.GetPhysicalAddress().Equals(PhysicalAddress.Parse(Program.MAC.Replace(":", "-").ToUpper()))) //Event filtering
                    {
                        wlanIface = wli;
                    }
                }
            }

            if (wlanIface != null)
            {
                ConnectionHelper ch = Program.toMihf;
                ID myLinkID         = new ID(new OctetString(GenericInfo.myID));
                ID mihfID           = new ID(new OctetString(GenericInfo.mihfID));

                if (Subscriptions.List.Link_Parameters_Report) //Generic subscription
                {
                    ch.Send(MessageBuilders.Link_Parameters_Report_Indication_MsgBuilder(
                                myLinkID, mihfID,
                                wlanIface.CurrentConnection.wlanAssociationAttributes.Dot11Bssid,
                                wlanIface.CurrentConnection.wlanAssociationAttributes.dot11Ssid.SSID,
                                Link_Param_Abs_Type.GEN_Sig_Strenth,
                                Link_Param_Gen.SignalStrength_1).ByteValue);
                }
                Reports.CheckThresholds(Link_Param_Abs_Type.GEN_Sig_Strenth, (int)wlanIface.RSSI);
            }
        }
    public void SendPingMessage(int x, int y)
    {
        Vector2 convertedCoord = model.PixelPosToTilePos(x, y);
        string  messageToSend  = MessageBuilders.BuildPingMessage(Mathf.FloorToInt(convertedCoord.x), Mathf.FloorToInt(convertedCoord.y));

        TCPClient.SendMessage(messageToSend);
    }
示例#5
0
    public void SendLeaveGameRequest()
    {
        string message = MessageBuilders.BuildLeaveGameMessage();

        if (message != "")
        {
            TCPClient.SendMessage(message);
        }
    }
示例#6
0
    public void SendMapChangeRequest(int index)
    {
        string message = MessageBuilders.BuildChangeMapMessage(GameLobbyData.MapList[index]);

        if (message != "")
        {
            TCPClient.SendMessage(message);
        }
    }
示例#7
0
    public void SendGameStartRequest()
    {
        string message = MessageBuilders.BuildStartGameMessage();

        if (message != "")
        {
            TCPClient.SendMessage(message);
        }
    }
示例#8
0
    public void SendRoleChangeRequest(int roleId)
    {
        string message = MessageBuilders.BuildChangeRoleMessage(roleId);

        if (message != "")
        {
            TCPClient.SendMessage(message);
        }
    }
    public void SendGameCreateRequest()
    {
        string messageToSend = MessageBuilders.BuildCreateGameMessage();

        if (messageToSend != "")
        {
            TCPClient.SendMessage(messageToSend);
        }
    }
    public void JoinGame()
    {
        string message = MessageBuilders.BuildJoinGameMessage(gameId);

        if (message != "")
        {
            TCPClient.SendMessage(message);
        }
    }
    public void SendGameListRequest()
    {
        string messageToSend = MessageBuilders.BuildGameListMessage();

        if (messageToSend != "")
        {
            TCPClient.SendMessage(messageToSend);
            lastRefresh = 0f;
        }
    }
示例#12
0
        public static void HandleScanComplete(Wlan.WlanNotificationData notifyData)
        {
            NativeWifi.WlanClient.WlanInterface wlanIface = null;// = GenericInfo.WlanInterface;
            foreach (NativeWifi.WlanClient.WlanInterface wli in Information.GenericInfo.ClientInstance.Interfaces)
            {
                if (wli.InterfaceGuid == notifyData.interfaceGuid)
                {
                    if (wli.NetworkInterface.GetPhysicalAddress().Equals(PhysicalAddress.Parse(Program.MAC.Replace(":", "-").ToUpper()))) //Event filtering
                    {
                        wlanIface = wli;
                    }
                }
            }

            if (wlanIface != null)
            {
                ConnectionHelper ch = Program.toMihf;
                ID myLinkID         = new ID(new OctetString(GenericInfo.myID));
                ID mihfID           = new ID(new OctetString(GenericInfo.mihfID));

                bool newLinks = wlanIface.UpdateSSIDs(wlanIface.GetNetworkBssList());
                if (wlanIface.ScanRequested)
                {
                    LINK_SAP_CS_80211.Common.Actions.ActionsInterface.FinishScanAction(); //Scan Actions from Link_Action.Requests are replied here.
                }
                wlanIface.ScanRequested = false;
                //LINK DETECTED INDICATION
                if (Subscriptions.List.Link_Detected)
                {
                    if (newLinks)
                    {
                        foreach (Wlan.WlanBssEntry entry in wlanIface.newConns)
                        {
                            ch.Send(MessageBuilders.Link_Detected_Indication_MsgBuilder(myLinkID, mihfID,
                                                                                        entry.dot11Bssid, entry.dot11Ssid.SSID, entry.linkQuality, entry.rssi, Utilities.getMax(entry.wlanRateSet.Rates)).ByteValue);
                        }
                    }
                }
            }
        }
示例#13
0
        public static void PeriodicReport(Object stateInfo)
        {
            Console.WriteLine("Periodic report called");
            Link_Param_Abs_Type lpat = (Link_Param_Abs_Type)stateInfo;

            Console.WriteLine("Reporting param type " + lpat);
            switch (lpat)
            {
            case Link_Param_Abs_Type.GEN_Sig_Strenth:
                Program.toMihf.Send(MessageBuilders.Link_Parameters_Report_Indication_MsgBuilder(
                                        new ID(new OctetString(GenericInfo.myID)),
                                        new ID(new OctetString(GenericInfo.mihfID)),
                                        GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.Dot11Bssid,
                                        GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.dot11Ssid.SSID,
                                        Link_Param_Abs_Type.GEN_Sig_Strenth,
                                        Link_Param_Gen.SignalStrength_1).ByteValue);
                break;

            case Link_Param_Abs_Type.GEN_Data_Rate:
                Program.toMihf.Send(MessageBuilders.Link_Parameters_Report_Indication_MsgBuilder(
                                        new ID(new OctetString(GenericInfo.myID)),
                                        new ID(new OctetString(GenericInfo.mihfID)),
                                        GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.Dot11Bssid,
                                        GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.dot11Ssid.SSID,
                                        Link_Param_Abs_Type.GEN_Data_Rate,
                                        Link_Param_Gen.DataRate_0).ByteValue);
                break;

            case Link_Param_Abs_Type.GEN_Packet_Error_Rate:
                Program.toMihf.Send(MessageBuilders.Link_Parameters_Report_Indication_MsgBuilder(
                                        new ID(new OctetString(GenericInfo.myID)),
                                        new ID(new OctetString(GenericInfo.mihfID)),
                                        GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.Dot11Bssid,
                                        GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.dot11Ssid.SSID,
                                        Link_Param_Abs_Type.GEN_Packet_Error_Rate,
                                        Link_Param_Gen.PacketErrorRate_4).ByteValue);
                break;
                //TODO other params
            }
        }
示例#14
0
        public static void CheckThresholds(Link_Param_Abs_Type type, int value)
        {
            foreach (ActiveThreshold a in OneShotThresholds)
            {
                if (a.Param_Type == type)
                {
                    if (a.CheckIfCrossed(value))
                    {
                        Program.toMihf.Send(MessageBuilders.Link_Parameters_Report_Indication_MsgBuilder(
                                                new ID(new OctetString(GenericInfo.myID)),
                                                new ID(new OctetString(GenericInfo.mihfID)),
                                                GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.Dot11Bssid,
                                                GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.dot11Ssid.SSID,
                                                type,
                                                GenericInfo.GetValueForParam(type)).ByteValue);
                        OneShotThresholds.Remove(a);
                    }
                }
            }

            foreach (ActiveThreshold a in ActiveThresholds)
            {
                if (a.Param_Type == type)
                {
                    if (a.CheckIfCrossed(value))
                    {
                        Program.toMihf.Send(MessageBuilders.Link_Parameters_Report_Indication_MsgBuilder(
                                                new ID(new OctetString(GenericInfo.myID)),
                                                new ID(new OctetString(GenericInfo.mihfID)),
                                                GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.Dot11Bssid,
                                                GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.dot11Ssid.SSID,
                                                type,
                                                GenericInfo.GetValueForParam(type)).ByteValue);
                    }
                }
            }
        }
    public void SendActionMessage()
    {
        string messageToSend = MessageBuilders.BuildActionMessage();

        TCPClient.SendMessage(messageToSend);
    }
    public void SendMoveMessage(string direction)
    {
        string messageToSend = MessageBuilders.BuildMovementMessage(direction);

        TCPClient.SendMessage(messageToSend);
    }