Пример #1
0
        private string PrintPlayer(Player player)
        {
            string text = string.Empty;

            text += "Player: [";
            if (player.HasIdentity)
            {
                this.PrintGameMasterIdentity(player.Identity);
            }
            int attributeCount = player.AttributeCount;

            text += "Attributes: ";
            for (int i = 0; i < attributeCount; i++)
            {
                bnet.protocol.attribute.Attribute attribute = player.Attribute[i];
                string text2 = text;
                text = string.Concat(new object[]
                {
                    text2,
                    "[Name: ",
                    attribute.Name,
                    " Value: ",
                    attribute.Value,
                    "] "
                });
            }
            return(text + "] ");
        }
Пример #2
0
        public void SendWhisper(BnetGameAccountId gameAccount, string message)
        {
            if (string.IsNullOrEmpty(message))
            {
                return;
            }
            Notification notification = new Notification();

            notification.SetType("WHISPER");
            bnet.protocol.EntityId entityId = new bnet.protocol.EntityId();
            entityId.SetLow(gameAccount.GetLo());
            entityId.SetHigh(gameAccount.GetHi());
            notification.SetTargetId(entityId);
            bnet.protocol.attribute.Attribute attribute = new bnet.protocol.attribute.Attribute();
            attribute.SetName("whisper");
            Variant variant = new Variant();

            variant.SetStringValue(message);
            attribute.SetValue(variant);
            notification.AddAttribute(attribute);
            this.m_rpcConnection.QueueRequest(this.m_battleNet.NotificationService.Id, 1u, notification, new RPCContextDelegate(this.WhisperSentCallback), 0u);
            BnetGameAccountId speakerId   = BnetGameAccountId.CreateFromEntityId(BattleNet.GetMyGameAccountId());
            BnetWhisper       bnetWhisper = new BnetWhisper();

            bnetWhisper.SetSpeakerId(speakerId);
            bnetWhisper.SetReceiverId(gameAccount);
            bnetWhisper.SetMessage(message);
            bnetWhisper.SetTimestampMilliseconds(TimeUtils.GetElapsedTimeSinceEpoch(null).TotalMilliseconds);
            this.m_whispers.Add(bnetWhisper);
        }
 public void SendWhisper(BnetGameAccountId gameAccount, string message)
 {
     if (!string.IsNullOrEmpty(message))
     {
         bnet.protocol.notification.Notification notification = new bnet.protocol.notification.Notification();
         notification.SetType("WHISPER");
         EntityId val = new EntityId();
         val.SetLow(gameAccount.GetLo());
         val.SetHigh(gameAccount.GetHi());
         notification.SetTargetId(val);
         bnet.protocol.attribute.Attribute attribute = new bnet.protocol.attribute.Attribute();
         attribute.SetName("whisper");
         bnet.protocol.attribute.Variant variant = new bnet.protocol.attribute.Variant();
         variant.SetStringValue(message);
         attribute.SetValue(variant);
         notification.AddAttribute(attribute);
         base.m_rpcConnection.QueueRequest(base.m_battleNet.NotificationService.Id, 1, notification, new RPCContextDelegate(this.WhisperSentCallback), 0);
         BnetGameAccountId id   = BnetGameAccountId.CreateFromDll(BattleNet.GetMyGameAccountId());
         BnetWhisper       item = new BnetWhisper();
         item.SetSpeakerId(id);
         item.SetReceiverId(gameAccount);
         item.SetMessage(message);
         TimeSpan elapsedTimeSinceEpoch = TimeUtils.GetElapsedTimeSinceEpoch(null);
         item.SetTimestampMilliseconds(elapsedTimeSinceEpoch.TotalMilliseconds);
         this.m_whispers.Add(item);
     }
 }
Пример #4
0
        public void OnWhisper(Notification notification)
        {
            if (!notification.HasSenderId)
            {
                return;
            }
            if (notification.AttributeCount <= 0)
            {
                return;
            }
            BnetWhisper bnetWhisper = new BnetWhisper();

            bnetWhisper.SetSpeakerId(BnetGameAccountId.CreateFromProtocol(notification.SenderId));
            bnetWhisper.SetReceiverId(BnetGameAccountId.CreateFromProtocol(notification.TargetId));
            for (int i = 0; i < notification.AttributeCount; i++)
            {
                bnet.protocol.attribute.Attribute attribute = notification.Attribute[i];
                if (attribute.Name == "whisper")
                {
                    bnetWhisper.SetMessage(attribute.Value.StringValue);
                }
            }
            if (string.IsNullOrEmpty(bnetWhisper.GetMessage()))
            {
                return;
            }
            bnetWhisper.SetTimestampMilliseconds(TimeUtils.GetElapsedTimeSinceEpoch(null).TotalMilliseconds);
            this.m_whispers.Add(bnetWhisper);
        }
    private void ClientRequestCallback(RPCContext context)
    {
        BattleNetErrors status = (BattleNetErrors)context.Header.Status;

        if (status != BattleNetErrors.ERROR_OK)
        {
            base.m_battleNet.EnqueueErrorInfo(BnetFeature.Games, BnetFeatureEvent.Games_OnClientRequest, status, context.Context);
        }
        else
        {
            ClientResponse response = ClientResponse.ParseFrom(context.Payload);
            if (response.AttributeCount >= 2)
            {
                bnet.protocol.attribute.Attribute attribute  = response.AttributeList[0];
                bnet.protocol.attribute.Attribute attribute2 = response.AttributeList[1];
                if (!attribute.Value.HasIntValue || !attribute2.Value.HasBlobValue)
                {
                    base.ApiLog.LogError("Malformed Attribute in Util Packet: incorrect values");
                }
                int           intValue  = (int)attribute.Value.IntValue;
                byte[]        blobValue = attribute2.Value.BlobValue;
                PegasusPacket item      = new PegasusPacket(intValue, blobValue.Length, blobValue)
                {
                    Context = context.Context
                };
                this.m_utilPackets.Enqueue(item);
            }
            else
            {
                base.ApiLog.LogError("Malformed Attribute in Util Packet: missing values");
            }
        }
    }
Пример #6
0
        public override void ListFactories(IRpcController controller, ListFactoriesRequest request, Action <ListFactoriesResponse> done)
        {
            GameFactoryDescription.Builder description = GameFactoryDescription.CreateBuilder().SetId(0xc5beec600d8c6273);

            var atributes = new[]
            {
                Attribute.CreateBuilder().SetName("min_players").SetValue(Variant.CreateBuilder().SetIntValue(2)).Build(),
                Attribute.CreateBuilder().SetName("max_players").SetValue(Variant.CreateBuilder().SetIntValue(4)).Build(),
                Attribute.CreateBuilder().SetName("num_teams").SetValue(Variant.CreateBuilder().SetIntValue(1)).Build(),
                Attribute.CreateBuilder().SetName("version").SetValue(Variant.CreateBuilder().SetStringValue("0.3.0")).Build()
            };

            description.AddRangeAttribute(atributes);
            description.AddStatsBucket(GameStatsBucket.CreateBuilder()
                                       .SetBucketMin(0)
                                       .SetBucketMax(4294967296F)
                                       .SetWaitMilliseconds(1354)
                                       .SetGamesPerHour(0)
                                       .SetActiveGames(1)
                                       .SetActivePlayers(1)
                                       .SetFormingGames(0)
                                       .SetWaitingPlayers(0)
                                       .Build());

            ListFactoriesResponse response = ListFactoriesResponse.CreateBuilder().AddDescription(description).SetTotalResults(1).Build();

            done(response);
        }
Пример #7
0
        private string PrintGameProperties(GameProperties properties)
        {
            string str;
            string empty = string.Empty;

            empty = "Game Properties: [";
            int creationAttributesCount = properties.CreationAttributesCount;

            empty = string.Concat(empty, "Creation Attributes: ");
            for (int i = 0; i < creationAttributesCount; i++)
            {
                bnet.protocol.attribute.Attribute item = properties.CreationAttributes[i];
                str   = empty;
                empty = string.Concat(new object[] { str, "[Name: ", item.Name, " Value: ", item.Value, "] " });
            }
            if (properties.HasFilter)
            {
                this.PrintGameMasterAttributeFilter(properties.Filter);
            }
            if (properties.HasCreate)
            {
                str   = empty;
                empty = string.Concat(new object[] { str, "Create New Game?: ", properties.Create, " " });
            }
            if (properties.HasOpen)
            {
                str   = empty;
                empty = string.Concat(new object[] { str, "Game Is Open?: ", properties.Open, " " });
            }
            if (properties.HasProgramId)
            {
                empty = string.Concat(empty, "Program Id(4CC): ", properties.ProgramId);
            }
            return(empty);
        }
Пример #8
0
        private void UtilClientRequestCallback(RPCContext context)
        {
            BattleNetErrors status = (BattleNetErrors)context.Header.Status;

            if (status != BattleNetErrors.ERROR_OK)
            {
                this.m_battleNet.EnqueueErrorInfo(BnetFeature.Games, BnetFeatureEvent.Games_OnClientRequest, status, 0);
                return;
            }
            ClientResponse clientResponse = ClientResponse.ParseFrom(context.Payload);

            if (clientResponse.AttributeCount >= 2)
            {
                bnet.protocol.attribute.Attribute attribute  = clientResponse.AttributeList[0];
                bnet.protocol.attribute.Attribute attribute2 = clientResponse.AttributeList[1];
                if (!attribute.Value.HasIntValue || !attribute2.Value.HasBlobValue)
                {
                    base.ApiLog.LogError("Malformed Attribute in Util Packet: incorrect values");
                }
                this.m_utilPackets.Enqueue(new GamesAPI.UtilResponse(clientResponse, context.Context));
            }
            else
            {
                base.ApiLog.LogError("Malformed Attribute in Util Packet: missing values");
            }
        }
 public static bnet.protocol.attribute.Attribute CreateAttribute(string name, ulong val)
 {
     bnet.protocol.attribute.Attribute attribute = new bnet.protocol.attribute.Attribute();
     bnet.protocol.attribute.Variant   variant   = new bnet.protocol.attribute.Variant();
     variant.SetUintValue(val);
     attribute.SetName(name);
     attribute.SetValue(variant);
     return(attribute);
 }
Пример #10
0
        public static bnet.protocol.attribute.Attribute CreateAttribute(string name, byte[] val)
        {
            bnet.protocol.attribute.Attribute attribute = new bnet.protocol.attribute.Attribute();
            Variant variant = new Variant();

            variant.SetBlobValue(val);
            attribute.SetName(name);
            attribute.SetValue(variant);
            return(attribute);
        }
Пример #11
0
 public void OnNotification(string notificationType, bnet.protocol.notification.Notification notification)
 {
     if (notification.AttributeCount > 0)
     {
         BnetNotification item = new BnetNotification(notificationType);
         SortedDictionary <string, int> dictionary = new SortedDictionary <string, int>();
         int num = 0;
         item.MessageType = 0;
         item.MessageSize = 0;
         for (int i = 0; i < notification.AttributeCount; i++)
         {
             bnet.protocol.attribute.Attribute attribute = notification.Attribute[i];
             if (attribute.Name == "message_type")
             {
                 item.MessageType = (int)attribute.Value.IntValue;
             }
             else if (attribute.Name == "message_size")
             {
                 item.MessageSize = (int)attribute.Value.IntValue;
             }
             else if (attribute.Name.StartsWith("fragment_"))
             {
                 num += attribute.Value.BlobValue.Length;
                 dictionary.Add(attribute.Name, i);
             }
         }
         if (item.MessageType == 0)
         {
             Debug.LogError(string.Format("Missing notification type {0} of size {1}", item.MessageType, item.MessageSize));
         }
         else
         {
             if (0 < num)
             {
                 byte[] blobValue;
                 item.BlobMessage = new byte[num];
                 SortedDictionary <string, int> .Enumerator enumerator = dictionary.GetEnumerator();
                 for (int j = 0; enumerator.MoveNext(); j += blobValue.Length)
                 {
                     KeyValuePair <string, int> current = enumerator.Current;
                     blobValue = notification.Attribute[current.Value].Value.BlobValue;
                     Array.Copy(blobValue, 0, item.BlobMessage, j, blobValue.Length);
                 }
             }
             if (item.MessageSize != num)
             {
                 Debug.LogError(string.Format("Message size mismatch for notification type {0} - {1} != {2}", item.MessageType, item.MessageSize, num));
             }
             else
             {
                 this.m_notifications.Add(item);
             }
         }
     }
 }
Пример #12
0
        public void OnNotification(string notificationType, Notification notification)
        {
            if (notification.AttributeCount <= 0)
            {
                return;
            }
            BnetNotification item = new BnetNotification(notificationType);
            SortedDictionary <string, int> sortedDictionary = new SortedDictionary <string, int>();
            int num = 0;

            item.MessageType = 0;
            item.MessageSize = 0;
            for (int i = 0; i < notification.AttributeCount; i++)
            {
                bnet.protocol.attribute.Attribute attribute = notification.Attribute[i];
                if (attribute.Name == "message_type")
                {
                    item.MessageType = (int)attribute.Value.IntValue;
                }
                else if (attribute.Name == "message_size")
                {
                    item.MessageSize = (int)attribute.Value.IntValue;
                }
                else if (attribute.Name.StartsWith("fragment_"))
                {
                    num += attribute.Value.BlobValue.Length;
                    sortedDictionary.Add(attribute.Name, i);
                }
            }
            if (item.MessageType == 0)
            {
                BattleNet.Log.LogError(string.Format("Missing notification type {0} of size {1}", item.MessageType, item.MessageSize));
                return;
            }
            if (0 < num)
            {
                item.BlobMessage = new byte[num];
                SortedDictionary <string, int> .Enumerator enumerator = sortedDictionary.GetEnumerator();
                int num2 = 0;
                while (enumerator.MoveNext())
                {
                    List <bnet.protocol.attribute.Attribute> attribute2 = notification.Attribute;
                    KeyValuePair <string, int> keyValuePair             = enumerator.Current;
                    byte[] blobValue = attribute2[keyValuePair.Value].Value.BlobValue;
                    Array.Copy(blobValue, 0, item.BlobMessage, num2, blobValue.Length);
                    num2 += blobValue.Length;
                }
            }
            if (item.MessageSize != num)
            {
                BattleNet.Log.LogError(string.Format("Message size mismatch for notification type {0} - {1} != {2}", item.MessageType, item.MessageSize, num));
                return;
            }
            this.m_notifications.Add(item);
        }
Пример #13
0
        private string PrintGameProperties(GameProperties properties)
        {
            string text = string.Empty;

            text = "Game Properties: [";
            int creationAttributesCount = properties.CreationAttributesCount;

            text += "Creation Attributes: ";
            for (int i = 0; i < creationAttributesCount; i++)
            {
                bnet.protocol.attribute.Attribute attribute = properties.CreationAttributes[i];
                string text2 = text;
                text = string.Concat(new object[]
                {
                    text2,
                    "[Name: ",
                    attribute.Name,
                    " Value: ",
                    attribute.Value,
                    "] "
                });
            }
            if (properties.HasFilter)
            {
                this.PrintGameMasterAttributeFilter(properties.Filter);
            }
            if (properties.HasCreate)
            {
                string text2 = text;
                text = string.Concat(new object[]
                {
                    text2,
                    "Create New Game?: ",
                    properties.Create,
                    " "
                });
            }
            if (properties.HasOpen)
            {
                string text2 = text;
                text = string.Concat(new object[]
                {
                    text2,
                    "Game Is Open?: ",
                    properties.Open,
                    " "
                });
            }
            if (properties.HasProgramId)
            {
                text = text + "Program Id(4CC): " + properties.ProgramId;
            }
            return(text);
        }
        public void OnNotification(string notificationType, Notification notification)
        {
            if (notification.AttributeCount <= 0)
            {
                return;
            }
            BnetNotification bnetNotification   = new BnetNotification(notificationType);
            SortedDictionary <string, int> strs = new SortedDictionary <string, int>();
            int length = 0;

            bnetNotification.MessageType = 0;
            bnetNotification.MessageSize = 0;
            for (int i = 0; i < notification.AttributeCount; i++)
            {
                bnet.protocol.attribute.Attribute item = notification.Attribute[i];
                if (item.Name == "message_type")
                {
                    bnetNotification.MessageType = (int)item.Value.IntValue;
                }
                else if (item.Name == "message_size")
                {
                    bnetNotification.MessageSize = (int)item.Value.IntValue;
                }
                else if (item.Name.StartsWith("fragment_"))
                {
                    length += (int)item.Value.BlobValue.Length;
                    strs.Add(item.Name, i);
                }
            }
            if (bnetNotification.MessageType == 0)
            {
                BattleNet.Log.LogError(string.Format("Missing notification type {0} of size {1}", bnetNotification.MessageType, bnetNotification.MessageSize));
                return;
            }
            if (0 < length)
            {
                bnetNotification.BlobMessage = new byte[length];
                SortedDictionary <string, int> .Enumerator enumerator = strs.GetEnumerator();
                int num = 0;
                while (enumerator.MoveNext())
                {
                    byte[] blobValue = notification.Attribute[enumerator.Current.Value].Value.BlobValue;
                    Array.Copy(blobValue, 0, bnetNotification.BlobMessage, num, (int)blobValue.Length);
                    num += (int)blobValue.Length;
                }
            }
            if (bnetNotification.MessageSize == length)
            {
                this.m_notifications.Add(bnetNotification);
                return;
            }
            BattleNet.Log.LogError(string.Format("Message size mismatch for notification type {0} - {1} != {2}", bnetNotification.MessageType, bnetNotification.MessageSize, length));
        }
Пример #15
0
        private string PrintGameMasterAttributeFilter(AttributeFilter filter)
        {
            string str;
            string str1 = "Attribute Filter: [";

            switch (filter.Op)
            {
            case AttributeFilter.Types.Operation.MATCH_NONE:
            {
                str = "MATCH_NONE";
                break;
            }

            case AttributeFilter.Types.Operation.MATCH_ANY:
            {
                str = "MATCH_ANY";
                break;
            }

            case AttributeFilter.Types.Operation.MATCH_ALL:
            {
                str = "MATCH_ALL";
                break;
            }

            case AttributeFilter.Types.Operation.MATCH_ALL_MOST_SPECIFIC:
            {
                str = "MATCH_ALL_MOST_SPECIFIC";
                break;
            }

            default:
            {
                str = "UNKNOWN";
                break;
            }
            }
            str1 = string.Concat(str1, "Operation: ", str, " ");
            str1 = string.Concat(str1, "Attributes: [");
            int attributeCount = filter.AttributeCount;

            for (int i = 0; i < attributeCount; i++)
            {
                bnet.protocol.attribute.Attribute item = filter.Attribute[i];
                string str2 = str1;
                str1 = string.Concat(new object[] { str2, "Name: ", item.Name, " Value: ", item.Value, " " });
            }
            str1 = string.Concat(str1, "] ");
            return(str1);
        }
Пример #16
0
        private string PrintGameMasterAttributeFilter(AttributeFilter filter)
        {
            string text = "Attribute Filter: [";
            string str;

            switch (filter.Op)
            {
            case AttributeFilter.Types.Operation.MATCH_NONE:
                str = "MATCH_NONE";
                break;

            case AttributeFilter.Types.Operation.MATCH_ANY:
                str = "MATCH_ANY";
                break;

            case AttributeFilter.Types.Operation.MATCH_ALL:
                str = "MATCH_ALL";
                break;

            case AttributeFilter.Types.Operation.MATCH_ALL_MOST_SPECIFIC:
                str = "MATCH_ALL_MOST_SPECIFIC";
                break;

            default:
                str = "UNKNOWN";
                break;
            }
            text  = text + "Operation: " + str + " ";
            text += "Attributes: [";
            int attributeCount = filter.AttributeCount;

            for (int i = 0; i < attributeCount; i++)
            {
                bnet.protocol.attribute.Attribute attribute = filter.Attribute[i];
                string text2 = text;
                text = string.Concat(new object[]
                {
                    text2,
                    "Name: ",
                    attribute.Name,
                    " Value: ",
                    attribute.Value,
                    " "
                });
            }
            return(text + "] ");
        }
    private string PrintPlayer(bnet.protocol.game_master.Player player)
    {
        string str = string.Empty + "Player: [";

        if (player.HasIdentity)
        {
            this.PrintGameMasterIdentity(player.Identity);
        }
        int attributeCount = player.AttributeCount;

        str = str + "Attributes: ";
        for (int i = 0; i < attributeCount; i++)
        {
            bnet.protocol.attribute.Attribute attribute = player.Attribute[i];
            string   str2      = str;
            object[] objArray1 = new object[] { str2, "[Name: ", attribute.Name, " Value: ", attribute.Value, "] " };
            str = string.Concat(objArray1);
        }
        return(str + "] ");
    }
Пример #18
0
        private string PrintPlayer(Player player)
        {
            string empty = string.Empty;

            empty = string.Concat(empty, "Player: [");
            if (player.HasIdentity)
            {
                this.PrintGameMasterIdentity(player.Identity);
            }
            int attributeCount = player.AttributeCount;

            empty = string.Concat(empty, "Attributes: ");
            for (int i = 0; i < attributeCount; i++)
            {
                bnet.protocol.attribute.Attribute item = player.Attribute[i];
                string str = empty;
                empty = string.Concat(new object[] { str, "[Name: ", item.Name, " Value: ", item.Value, "] " });
            }
            empty = string.Concat(empty, "] ");
            return(empty);
        }
Пример #19
0
        public override void FindGame(IRpcController controller, FindGameRequest request, Action <FindGameResponse> done)
        {
            FindGameResponse.Builder findGameResponse = FindGameResponse.CreateBuilder();
            findGameResponse.SetRequestId(12526585062881647236);

            done(findGameResponse.Build());

            client.ListenerId = request.ObjectId;

            GameFoundNotification.Builder gameFoundNotification = GameFoundNotification.CreateBuilder();

            GameHandle.Builder gameHandle = GameHandle.CreateBuilder();
            gameHandle.SetFactoryId(request.FactoryId);
            gameHandle.SetGameId(EntityId.CreateBuilder().SetHigh(433661094641971304).SetLow(11017467167309309688).Build());

            ConnectInfo.Builder connectInfo = ConnectInfo.CreateBuilder();
            connectInfo.SetToonId(new EntityId.Builder
            {
                High = HighId.Toon,
                Low  = 2
            }.Build());
            connectInfo.SetHost("127.0.0.1");
            connectInfo.SetPort(6665);
            connectInfo.SetToken(ByteString.CopyFrom(new byte[] { 0x07, 0x34, 0x02, 0x60, 0x91, 0x93, 0x76, 0x46, 0x28, 0x84 }));
            connectInfo.AddAttribute(Attribute
                                     .CreateBuilder()
                                     .SetName("SGameId")
                                     .SetValue(Variant
                                               .CreateBuilder()
                                               .SetIntValue(2014314530)
                                               .Build())
                                     .Build());

            gameFoundNotification.SetRequestId(12526585062881647236);
            gameFoundNotification.SetGameHandle(gameHandle.Build());
            gameFoundNotification.AddConnectInfo(connectInfo.Build());

            GameFactorySubscriber.CreateStub(client).NotifyGameFound(controller, gameFoundNotification.Build(), r => { });
        }
    private string PrintGameMasterAttributeFilter(AttributeFilter filter)
    {
        string str2;
        string str = "Attribute Filter: [";

        switch (filter.Op)
        {
        case AttributeFilter.Types.Operation.MATCH_NONE:
            str2 = "MATCH_NONE";
            break;

        case AttributeFilter.Types.Operation.MATCH_ANY:
            str2 = "MATCH_ANY";
            break;

        case AttributeFilter.Types.Operation.MATCH_ALL:
            str2 = "MATCH_ALL";
            break;

        case AttributeFilter.Types.Operation.MATCH_ALL_MOST_SPECIFIC:
            str2 = "MATCH_ALL_MOST_SPECIFIC";
            break;

        default:
            str2 = "UNKNOWN";
            break;
        }
        str = (str + "Operation: " + str2 + " ") + "Attributes: [";
        int attributeCount = filter.AttributeCount;

        for (int i = 0; i < attributeCount; i++)
        {
            bnet.protocol.attribute.Attribute attribute = filter.Attribute[i];
            string   str3      = str;
            object[] objArray1 = new object[] { str3, "Name: ", attribute.Name, " Value: ", attribute.Value, " " };
            str = string.Concat(objArray1);
        }
        return(str + "] ");
    }
    private string PrintGameProperties(GameProperties properties)
    {
        string str2;
        string str = string.Empty;

        str = "Game Properties: [";
        int creationAttributesCount = properties.CreationAttributesCount;

        str = str + "Creation Attributes: ";
        for (int i = 0; i < creationAttributesCount; i++)
        {
            bnet.protocol.attribute.Attribute attribute = properties.CreationAttributes[i];
            str2 = str;
            object[] objArray1 = new object[] { str2, "[Name: ", attribute.Name, " Value: ", attribute.Value, "] " };
            str = string.Concat(objArray1);
        }
        if (properties.HasFilter)
        {
            this.PrintGameMasterAttributeFilter(properties.Filter);
        }
        if (properties.HasCreate)
        {
            str2 = str;
            object[] objArray2 = new object[] { str2, "Create New Game?: ", properties.Create, " " };
            str = string.Concat(objArray2);
        }
        if (properties.HasOpen)
        {
            str2 = str;
            object[] objArray3 = new object[] { str2, "Game Is Open?: ", properties.Open, " " };
            str = string.Concat(objArray3);
        }
        if (properties.HasProgramId)
        {
            str = str + "Program Id(4CC): " + properties.ProgramId;
        }
        return(str);
    }
 public void OnWhisper(bnet.protocol.notification.Notification notification)
 {
     if (notification.HasSenderId && (notification.AttributeCount > 0))
     {
         BnetWhisper item = new BnetWhisper();
         item.SetSpeakerId(BnetGameAccountId.CreateFromProtocol(notification.SenderId));
         item.SetReceiverId(BnetGameAccountId.CreateFromProtocol(notification.TargetId));
         for (int i = 0; i < notification.AttributeCount; i++)
         {
             bnet.protocol.attribute.Attribute attribute = notification.Attribute[i];
             if (attribute.Name == "whisper")
             {
                 item.SetMessage(attribute.Value.StringValue);
             }
         }
         if (!string.IsNullOrEmpty(item.GetMessage()))
         {
             TimeSpan elapsedTimeSinceEpoch = TimeUtils.GetElapsedTimeSinceEpoch(null);
             item.SetTimestampMilliseconds(elapsedTimeSinceEpoch.TotalMilliseconds);
             this.m_whispers.Add(item);
         }
     }
 }
Пример #23
0
 public void AddAttribute(bnet.protocol.attribute.Attribute val)
 {
     this._Attribute.Add(val);
 }
Пример #24
0
        private void HandleChannelSubscriber_NotifyUpdateChannelState(RPCContext context)
        {
            UpdateChannelStateNotification updateChannelStateNotification = UpdateChannelStateNotification.ParseFrom(context.Payload);

            base.ApiLog.LogDebug("HandleChannelSubscriber_NotifyUpdateChannelState: " + updateChannelStateNotification);
            ChannelAPI.ChannelReferenceObject channelReferenceObject = this.GetChannelReferenceObject(context.Header.ObjectId);
            if (channelReferenceObject == null)
            {
                base.ApiLog.LogError("HandleChannelSubscriber_NotifyUpdateChannelState had unexpected traffic for objectId : " + context.Header.ObjectId);
                return;
            }
            ChannelAPI.ChannelType channelType = channelReferenceObject.m_channelData.m_channelType;
            switch (channelType)
            {
            case ChannelAPI.ChannelType.PRESENCE_CHANNEL:
                if (updateChannelStateNotification.StateChange.HasPresence)
                {
                    bnet.protocol.presence.ChannelState presence = updateChannelStateNotification.StateChange.Presence;
                    this.m_battleNet.Presence.HandlePresenceUpdates(presence, channelReferenceObject);
                }
                return;

            case ChannelAPI.ChannelType.CHAT_CHANNEL:
            case ChannelAPI.ChannelType.GAME_CHANNEL:
                break;

            case ChannelAPI.ChannelType.PARTY_CHANNEL:
                this.m_battleNet.Party.PreprocessPartyChannelUpdated(channelReferenceObject, updateChannelStateNotification);
                break;

            default:
                return;
            }
            ChannelAPI.ChannelData channelData = (ChannelAPI.ChannelData)channelReferenceObject.m_channelData;
            if (channelData != null)
            {
                bool flag  = channelType == ChannelAPI.ChannelType.PARTY_CHANNEL;
                bool flag2 = false;
                Map <string, Variant> map = null;
                bnet.protocol.channel.ChannelState channelState = channelData.m_channelState;
                bnet.protocol.channel.ChannelState stateChange  = updateChannelStateNotification.StateChange;
                if (stateChange.HasMaxMembers)
                {
                    channelState.MaxMembers = stateChange.MaxMembers;
                }
                if (stateChange.HasMinMembers)
                {
                    channelState.MinMembers = stateChange.MinMembers;
                }
                if (stateChange.HasMaxInvitations)
                {
                    channelState.MaxInvitations = stateChange.MaxInvitations;
                }
                if (stateChange.HasPrivacyLevel && channelState.PrivacyLevel != stateChange.PrivacyLevel)
                {
                    channelState.PrivacyLevel = stateChange.PrivacyLevel;
                    flag2 = true;
                }
                if (stateChange.HasName)
                {
                    channelState.Name = stateChange.Name;
                }
                if (stateChange.HasDelegateName)
                {
                    channelState.DelegateName = stateChange.DelegateName;
                }
                if (stateChange.HasChannelType)
                {
                    if (!flag)
                    {
                        channelState.ChannelType = stateChange.ChannelType;
                    }
                    if (flag && stateChange.ChannelType != PartyAPI.PARTY_TYPE_DEFAULT)
                    {
                        channelState.ChannelType = stateChange.ChannelType;
                        int num = -1;
                        for (int i = 0; i < channelState.AttributeList.Count; i++)
                        {
                            if (channelState.AttributeList[i].Name == "WTCG.Party.Type")
                            {
                                num = i;
                                break;
                            }
                        }
                        bnet.protocol.attribute.Attribute attribute = ProtocolHelper.CreateAttribute("WTCG.Party.Type", channelState.ChannelType);
                        if (num >= 0)
                        {
                            channelState.AttributeList[num] = attribute;
                        }
                        else
                        {
                            channelState.AttributeList.Add(attribute);
                        }
                    }
                }
                if (stateChange.HasProgram)
                {
                    channelState.Program = stateChange.Program;
                }
                if (stateChange.HasAllowOfflineMembers)
                {
                    channelState.AllowOfflineMembers = stateChange.AllowOfflineMembers;
                }
                if (stateChange.HasSubscribeToPresence)
                {
                    channelState.SubscribeToPresence = stateChange.SubscribeToPresence;
                }
                if (stateChange.AttributeCount > 0 && map == null)
                {
                    map = new Map <string, Variant>();
                }
                for (int j = 0; j < stateChange.AttributeCount; j++)
                {
                    bnet.protocol.attribute.Attribute attribute2 = stateChange.AttributeList[j];
                    int num2 = -1;
                    for (int k = 0; k < channelState.AttributeList.Count; k++)
                    {
                        bnet.protocol.attribute.Attribute attribute3 = channelState.AttributeList[k];
                        if (attribute3.Name == attribute2.Name)
                        {
                            num2 = k;
                            break;
                        }
                    }
                    if (attribute2.Value.IsNone())
                    {
                        if (num2 >= 0)
                        {
                            channelState.AttributeList.RemoveAt(num2);
                        }
                    }
                    else if (num2 >= 0)
                    {
                        channelState.Attribute[num2] = attribute2;
                    }
                    else
                    {
                        channelState.AddAttribute(attribute2);
                    }
                    map.Add(attribute2.Name, attribute2.Value);
                }
                if (stateChange.HasReason)
                {
                    IList <Invitation> invitationList  = stateChange.InvitationList;
                    IList <Invitation> invitationList2 = channelState.InvitationList;
                    for (int l = 0; l < invitationList.Count; l++)
                    {
                        Invitation invitation = invitationList[l];
                        for (int m = 0; m < invitationList2.Count; m++)
                        {
                            Invitation invitation2 = invitationList2[m];
                            if (invitation2.Id == invitation.Id)
                            {
                                channelState.InvitationList.RemoveAt(m);
                                break;
                            }
                        }
                    }
                }
                else
                {
                    channelState.Invitation.AddRange(stateChange.InvitationList);
                }
                channelData.m_channelState = channelState;
                if (flag)
                {
                    if (flag2)
                    {
                        this.m_battleNet.Party.PartyPrivacyChanged(channelData.m_channelId, channelState.PrivacyLevel);
                    }
                    if (stateChange.InvitationList.Count > 0)
                    {
                        uint?removeReason = null;
                        if (stateChange.HasReason)
                        {
                            removeReason = new uint?(stateChange.Reason);
                        }
                        foreach (Invitation invite in stateChange.InvitationList)
                        {
                            this.m_battleNet.Party.PartyInvitationDelta(channelData.m_channelId, invite, removeReason);
                        }
                    }
                    if (map != null)
                    {
                        foreach (KeyValuePair <string, Variant> keyValuePair in map)
                        {
                            this.m_battleNet.Party.PartyAttributeChanged(channelData.m_channelId, keyValuePair.Key, keyValuePair.Value);
                        }
                    }
                }
            }
        }
Пример #25
0
        private void HandleChannelSubscriber_NotifyUpdateMemberState(RPCContext context)
        {
            UpdateMemberStateNotification updateMemberStateNotification = UpdateMemberStateNotification.ParseFrom(context.Payload);

            base.ApiLog.LogDebug("HandleChannelSubscriber_NotifyUpdateMemberState: " + updateMemberStateNotification);
            ChannelAPI.ChannelReferenceObject channelReferenceObject = this.GetChannelReferenceObject(context.Header.ObjectId);
            if (channelReferenceObject == null)
            {
                base.ApiLog.LogError("HandleChannelSubscriber_NotifyUpdateMemberState had unexpected traffic for objectId : " + context.Header.ObjectId);
                return;
            }
            ChannelAPI.ChannelType channelType = channelReferenceObject.m_channelData.m_channelType;
            ChannelAPI.ChannelData channelData = (ChannelAPI.ChannelData)channelReferenceObject.m_channelData;
            EntityId        channelId          = channelData.m_channelId;
            List <EntityId> list = null;

            for (int i = 0; i < updateMemberStateNotification.StateChangeList.Count; i++)
            {
                Member deltaMember = updateMemberStateNotification.StateChangeList[i];
                if (!deltaMember.Identity.HasGameAccountId)
                {
                    base.ApiLog.LogError("HandleChannelSubscriber_NotifyUpdateMemberState no identity/gameAccount in Member list at index={0} channelId={1}-{2}", new object[]
                    {
                        i,
                        channelId.High,
                        channelId.Low
                    });
                }
                else
                {
                    EntityId gameAccountId    = deltaMember.Identity.GameAccountId;
                    Map <string, Variant> map = null;
                    Member member;
                    Member cachedMember;
                    if (!channelData.m_members.TryGetValue(gameAccountId, out cachedMember))
                    {
                        member = deltaMember;
                    }
                    else
                    {
                        Member      cachedMember2 = cachedMember;
                        MemberState state         = cachedMember.State;
                        if (deltaMember.State.AttributeCount > 0)
                        {
                            if (map == null)
                            {
                                map = new Map <string, Variant>();
                            }
                            for (int j = 0; j < deltaMember.State.AttributeCount; j++)
                            {
                                bnet.protocol.attribute.Attribute attribute = deltaMember.State.AttributeList[j];
                                int num = -1;
                                for (int k = 0; k < state.AttributeList.Count; k++)
                                {
                                    bnet.protocol.attribute.Attribute attribute2 = state.AttributeList[k];
                                    if (attribute2.Name == attribute.Name)
                                    {
                                        num = k;
                                        break;
                                    }
                                }
                                if (attribute.Value.IsNone())
                                {
                                    if (num >= 0)
                                    {
                                        state.AttributeList.RemoveAt(num);
                                    }
                                }
                                else if (num >= 0)
                                {
                                    state.Attribute[num] = attribute;
                                }
                                else
                                {
                                    state.AddAttribute(attribute);
                                }
                                map.Add(attribute.Name, attribute.Value);
                            }
                        }
                        else
                        {
                            if (deltaMember.State.HasPrivileges)
                            {
                                state.Privileges = deltaMember.State.Privileges;
                            }
                            if (cachedMember.State.RoleCount != deltaMember.State.RoleCount || !cachedMember.State.RoleList.All((uint roleId) => deltaMember.State.RoleList.Contains(roleId)) || !deltaMember.State.RoleList.All((uint roleId) => cachedMember.State.RoleList.Contains(roleId)))
                            {
                                if (list == null)
                                {
                                    list = new List <EntityId>();
                                }
                                list.Add(gameAccountId);
                                state.ClearRole();
                                state.Role.AddRange(deltaMember.State.RoleList);
                            }
                            if (deltaMember.State.HasInfo)
                            {
                                if (state.HasInfo)
                                {
                                    if (deltaMember.State.Info.HasBattleTag)
                                    {
                                        state.Info.SetBattleTag(deltaMember.State.Info.BattleTag);
                                    }
                                }
                                else
                                {
                                    state.SetInfo(deltaMember.State.Info);
                                }
                            }
                        }
                        cachedMember2.SetState(state);
                        member = cachedMember2;
                    }
                    if (member != null)
                    {
                        channelData.m_members[gameAccountId] = member;
                    }
                    if (map != null)
                    {
                    }
                }
            }
            if (list != null)
            {
                bool flag = channelType == ChannelAPI.ChannelType.PARTY_CHANNEL;
                if (flag)
                {
                    this.m_battleNet.Party.MemberRolesChanged(channelReferenceObject, list);
                }
            }
        }
Пример #26
0
 public void AddCreationAttributes(bnet.protocol.attribute.Attribute val)
 {
     this._CreationAttributes.Add(val);
 }