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");
            bnet.protocol.attribute.Variant variant = new bnet.protocol.attribute.Variant();
            variant.SetStringValue(message);
            attribute.SetValue(variant);
            notification.AddAttribute(attribute);
            this.m_rpcConnection.QueueRequest(this.m_battleNet.NotificationService.Id, 1, notification, new RPCContextDelegate(this.WhisperSentCallback), 0);
            BnetGameAccountId bnetGameAccountId = BnetGameAccountId.CreateFromEntityId(BattleNet.GetMyGameAccountId());
            BnetWhisper       bnetWhisper       = new BnetWhisper();

            bnetWhisper.SetSpeakerId(bnetGameAccountId);
            bnetWhisper.SetReceiverId(gameAccount);
            bnetWhisper.SetMessage(message);
            bnetWhisper.SetTimestampMilliseconds(TimeUtils.GetElapsedTimeSinceEpoch(null).TotalMilliseconds);
            this.m_whispers.Add(bnetWhisper);
        }
Exemplo n.º 2
0
        private bool FetchRichPresenceResource(bnet.protocol.attribute.Variant presenceValue)
        {
            if (presenceValue == null)
            {
                return(false);
            }
            RichPresence richPresence = RichPresence.ParseFrom(presenceValue.MessageValue);

            if (richPresence == null || !richPresence.IsInitialized)
            {
                base.ApiLog.LogError("Rich presence field from battle.net does not contain valid RichPresence message");
                return(false);
            }
            if (this.m_richPresenceStringTables.ContainsKey(richPresence))
            {
                return(false);
            }
            FourCC fourCC  = new FourCC(richPresence.ProgramId);
            FourCC fourCC1 = new FourCC(richPresence.StreamId);
            FourCC fourCC2 = new FourCC(BattleNet.Client().GetLocaleName());

            this.IncrementOutstandingRichPresenceStringFetches();
            ResourcesAPI resources = this.m_battleNet.Resources;

            resources.LookupResource(fourCC, fourCC1, fourCC2, new ResourcesAPI.ResourceLookupCallback(this.ResouceLookupCallback), richPresence);
            return(true);
        }
Exemplo n.º 3
0
        public void SetPresenceBlob(uint field, byte[] val)
        {
            UpdateRequest updateRequest = new UpdateRequest()
            {
                EntityId = this.m_battleNet.GameAccountId
            };
            FieldOperation fieldOperation = new FieldOperation();
            Field          field1         = new Field();
            FieldKey       fieldKey       = new FieldKey();

            fieldKey.SetProgram(BnetProgramId.WOW.GetValue());
            fieldKey.SetGroup(2);
            fieldKey.SetField(field);
            bnet.protocol.attribute.Variant variant = new bnet.protocol.attribute.Variant();
            if (val == null)
            {
                val = new byte[0];
            }
            variant.SetBlobValue(val);
            field1.SetKey(fieldKey);
            field1.SetValue(variant);
            fieldOperation.SetField(field1);
            updateRequest.SetEntityId(this.m_battleNet.GameAccountId);
            updateRequest.AddFieldOperation(fieldOperation);
            this.PublishField(updateRequest);
        }
Exemplo n.º 4
0
        public void PublishRichPresence([In] RichPresenceUpdate[] updates)
        {
            UpdateRequest updateRequest = new UpdateRequest()
            {
                EntityId = this.m_battleNet.GameAccountId
            };
            FieldOperation fieldOperation = new FieldOperation();
            Field          field          = new Field();
            FieldKey       fieldKey       = new FieldKey();

            fieldKey.SetProgram(BnetProgramId.BNET.GetValue());
            fieldKey.SetGroup(2);
            fieldKey.SetField(8);
            RichPresenceUpdate[] richPresenceUpdateArray = updates;
            for (int i = 0; i < (int)richPresenceUpdateArray.Length; i++)
            {
                RichPresenceUpdate richPresenceUpdate = richPresenceUpdateArray[i];
                fieldKey.SetIndex(richPresenceUpdate.presenceFieldIndex);
                RichPresence richPresence = new RichPresence();
                richPresence.SetIndex(richPresenceUpdate.index);
                richPresence.SetProgramId(richPresenceUpdate.programId);
                richPresence.SetStreamId(richPresenceUpdate.streamId);
                bnet.protocol.attribute.Variant variant = new bnet.protocol.attribute.Variant();
                variant.SetMessageValue(ProtobufUtil.ToByteArray(richPresence));
                field.SetKey(fieldKey);
                field.SetValue(variant);
                fieldOperation.SetField(field);
                updateRequest.SetEntityId(this.m_battleNet.GameAccountId);
                updateRequest.AddFieldOperation(fieldOperation);
            }
            this.PublishField(updateRequest);
        }
 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);
     }
 }
Exemplo n.º 6
0
    public void PublishRichPresence([In] BattleNet.DllRichPresenceUpdate[] updates)
    {
        UpdateRequest updateRequest = new UpdateRequest {
            EntityId = base.m_battleNet.GameAccountId
        };
        FieldOperation val   = new FieldOperation();
        Field          field = new Field();
        FieldKey       key   = new FieldKey();

        key.SetProgram(BnetProgramId.BNET.GetValue());
        key.SetGroup(2);
        key.SetField(8);
        foreach (BattleNet.DllRichPresenceUpdate update in updates)
        {
            key.SetIndex(update.presenceFieldIndex);
            bnet.protocol.presence.RichPresence protobuf = new bnet.protocol.presence.RichPresence();
            protobuf.SetIndex(update.index);
            protobuf.SetProgramId(update.programId);
            protobuf.SetStreamId(update.streamId);
            bnet.protocol.attribute.Variant variant = new bnet.protocol.attribute.Variant();
            variant.SetMessageValue(ProtobufUtil.ToByteArray(protobuf));
            field.SetKey(key);
            field.SetValue(variant);
            val.SetField(field);
            updateRequest.SetEntityId(base.m_battleNet.GameAccountId);
            updateRequest.AddFieldOperation(val);
        }
        this.PublishField(updateRequest);
    }
 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);
 }
Exemplo n.º 8
0
 public void SetCache(bgs.types.EntityId entity, FieldKey key, bnet.protocol.attribute.Variant value)
 {
     if (key == null)
     {
         return;
     }
     if (!base.ContainsKey(entity))
     {
         base[entity] = new PresenceAPI.FieldKeyToPresenceMap();
     }
     base[entity][key] = value;
 }
Exemplo n.º 9
0
        private bool ResolveRichPresenceStrings(out string richPresenceString, bgs.types.EntityId entityId, ulong index, int recurseDepth)
        {
            richPresenceString = string.Empty;
            FieldKey fieldKey = new FieldKey();

            fieldKey.SetProgram(BnetProgramId.BNET.GetValue());
            fieldKey.SetGroup(2);
            fieldKey.SetField(8);
            fieldKey.SetIndex(index);
            bnet.protocol.attribute.Variant cache = this.m_presenceCache.GetCache(entityId, fieldKey);
            if (cache == null)
            {
                base.ApiLog.LogError("Expected field missing from presence cache when resolving rich presence string");
                return(false);
            }
            RichPresence richPresence = RichPresence.ParseFrom(cache.MessageValue);

            if (richPresence == null || !richPresence.IsInitialized)
            {
                base.ApiLog.LogError("Rich presence field did not contain valid RichPresence message when resolving");
                return(false);
            }
            if (!this.m_richPresenceStringTables.ContainsKey(richPresence))
            {
                return(false);
            }
            PresenceAPI.IndexToStringMap item = this.m_richPresenceStringTables[richPresence];
            if (!item.ContainsKey((ulong)richPresence.Index))
            {
                base.ApiLog.LogWarning("Rich presence string table data is missing");
                return(false);
            }
            richPresenceString = item[(ulong)richPresence.Index];
            if (recurseDepth >= 1 || this.SubstituteVariables(out richPresenceString, richPresenceString, entityId, recurseDepth + 1))
            {
                return(true);
            }
            base.ApiLog.LogWarning("Failed to substitute rich presence variables in: {0}", new object[] { richPresenceString });
            return(false);
        }
Exemplo n.º 10
0
 private void BnetParty_OnPartyAttributeChanged_Error(PartyInfo party, string attributeKey, bnet.protocol.attribute.Variant value)
 {
     if (party.Type == PartyType.FRIENDLY_CHALLENGE)
     {
         if (this.DidReceiveChallenge() && value.HasIntValue)
         {
             object[] args = new object[] { value.IntValue };
             Log.Party.Print(LogLevel.Error, "BnetParty_OnPartyAttributeChanged_Error - code={0}", args);
             BnetErrorInfo info = new BnetErrorInfo(BnetFeature.Games, BnetFeatureEvent.Games_OnCreated, (BattleNetErrors)((uint)value.IntValue));
             GameMgr.Get().OnBnetError(info, null);
         }
         if (BnetParty.IsLeader(party.Id) && !value.IsNone())
         {
             BnetParty.ClearPartyAttribute(party.Id, attributeKey);
         }
     }
 }
Exemplo n.º 11
0
    private void BnetParty_OnPartyAttributeChanged_DeclineReason(PartyInfo party, string attributeKey, bnet.protocol.attribute.Variant value)
    {
        if (((party.Type == PartyType.FRIENDLY_CHALLENGE) && this.DidSendChallenge()) && value.HasIntValue)
        {
            DeclineReason intValue = (DeclineReason)((int)value.IntValue);
            string        key      = null;
            switch (intValue)
            {
            case DeclineReason.NoValidDeck:
                key = "GLOBAL_FRIEND_CHALLENGE_TAVERN_BRAWL_RECIPIENT_NO_VALID_DECK_SENDER";
                break;

            case DeclineReason.NotUnlocked:
                key = "GLOBAL_FRIEND_CHALLENGE_TAVERN_BRAWL_RECIPIENT_NOT_UNLOCKED_SENDER";
                break;
            }
            if (key != null)
            {
                this.m_hasSeenDeclinedReason = true;
                AlertPopup.PopupInfo info = new AlertPopup.PopupInfo {
                    m_headerText      = GameStrings.Get("GLOBAL_FRIEND_CHALLENGE_TAVERN_BRAWL_HEADER"),
                    m_text            = GameStrings.Get(key),
                    m_responseDisplay = AlertPopup.ResponseDisplay.OK
                };
                DialogManager.Get().ShowPopup(info);
            }
        }
    }
Exemplo n.º 12
0
 public void Serialize(Stream stream)
 {
     Variant.Serialize(stream, this);
 }
Exemplo n.º 13
0
        public static Variant Deserialize(Stream stream, Variant instance, long limit)
        {
            BinaryReader binaryReader = new BinaryReader(stream);

            while (limit < 0L || stream.Position < limit)
            {
                int num = stream.ReadByte();
                if (num == -1)
                {
                    if (limit >= 0L)
                    {
                        throw new EndOfStreamException();
                    }
                    return(instance);
                }
                else if (num != 16)
                {
                    if (num != 24)
                    {
                        if (num != 33)
                        {
                            if (num != 42)
                            {
                                if (num != 50)
                                {
                                    if (num != 58)
                                    {
                                        if (num != 66)
                                        {
                                            if (num != 72)
                                            {
                                                if (num != 82)
                                                {
                                                    Key  key   = ProtocolParser.ReadKey((byte)num, stream);
                                                    uint field = key.Field;
                                                    if (field == 0u)
                                                    {
                                                        throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                                                    }
                                                    ProtocolParser.SkipKey(stream, key);
                                                }
                                                else if (instance.EntityidValue == null)
                                                {
                                                    instance.EntityidValue = EntityId.DeserializeLengthDelimited(stream);
                                                }
                                                else
                                                {
                                                    EntityId.DeserializeLengthDelimited(stream, instance.EntityidValue);
                                                }
                                            }
                                            else
                                            {
                                                instance.UintValue = ProtocolParser.ReadUInt64(stream);
                                            }
                                        }
                                        else
                                        {
                                            instance.FourccValue = ProtocolParser.ReadString(stream);
                                        }
                                    }
                                    else
                                    {
                                        instance.MessageValue = ProtocolParser.ReadBytes(stream);
                                    }
                                }
                                else
                                {
                                    instance.BlobValue = ProtocolParser.ReadBytes(stream);
                                }
                            }
                            else
                            {
                                instance.StringValue = ProtocolParser.ReadString(stream);
                            }
                        }
                        else
                        {
                            instance.FloatValue = binaryReader.ReadDouble();
                        }
                    }
                    else
                    {
                        instance.IntValue = (long)ProtocolParser.ReadUInt64(stream);
                    }
                }
                else
                {
                    instance.BoolValue = ProtocolParser.ReadBool(stream);
                }
            }
            if (stream.Position == limit)
            {
                return(instance);
            }
            throw new ProtocolBufferException("Read past max limit");
        }
Exemplo n.º 14
0
 public void Deserialize(Stream stream)
 {
     Variant.Deserialize(stream, this);
 }
Exemplo n.º 15
0
        public override bool Equals(object obj)
        {
            Variant variant = obj as Variant;

            return(variant != null && this.HasBoolValue == variant.HasBoolValue && (!this.HasBoolValue || this.BoolValue.Equals(variant.BoolValue)) && this.HasIntValue == variant.HasIntValue && (!this.HasIntValue || this.IntValue.Equals(variant.IntValue)) && this.HasFloatValue == variant.HasFloatValue && (!this.HasFloatValue || this.FloatValue.Equals(variant.FloatValue)) && this.HasStringValue == variant.HasStringValue && (!this.HasStringValue || this.StringValue.Equals(variant.StringValue)) && this.HasBlobValue == variant.HasBlobValue && (!this.HasBlobValue || this.BlobValue.Equals(variant.BlobValue)) && this.HasMessageValue == variant.HasMessageValue && (!this.HasMessageValue || this.MessageValue.Equals(variant.MessageValue)) && this.HasFourccValue == variant.HasFourccValue && (!this.HasFourccValue || this.FourccValue.Equals(variant.FourccValue)) && this.HasUintValue == variant.HasUintValue && (!this.HasUintValue || this.UintValue.Equals(variant.UintValue)) && this.HasEntityidValue == variant.HasEntityidValue && (!this.HasEntityidValue || this.EntityidValue.Equals(variant.EntityidValue)));
        }
Exemplo n.º 16
0
 public void SetValue(bnet.protocol.attribute.Variant val)
 {
     this.Value = val;
 }
Exemplo n.º 17
0
 public static Variant Deserialize(Stream stream, Variant instance)
 {
     return(Variant.Deserialize(stream, instance, -1L));
 }
 public static bool IsNone(this bnet.protocol.attribute.Variant val)
 {
     return(val.HasBoolValue || val.HasIntValue || val.HasFloatValue || val.HasStringValue || val.HasBlobValue || val.HasMessageValue || val.HasFourccValue || val.HasUintValue ? false : !val.HasEntityidValue);
 }