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);
            Attribute attribute = new 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(default(DateTime?)).get_TotalMilliseconds());
            this.m_whispers.Add(bnetWhisper);
        }
Exemplo n.º 2
0
 public static bnet.protocol.EntityId CreateForProtocol(BnetEntityId src)
 {
     bnet.protocol.EntityId entityId = new bnet.protocol.EntityId();
     entityId.SetLow(src.GetLo());
     entityId.SetHigh(src.GetHi());
     return(entityId);
 }
 public bnet.protocol.EntityId ToProtocol()
 {
     bnet.protocol.EntityId entityId = new bnet.protocol.EntityId();
     entityId.SetHigh(this.hi);
     entityId.SetLow(this.lo);
     return(entityId);
 }
        private void HandleLogonCompleteRequest(RPCContext context)
        {
            LogonResult     logonResult = LogonResult.ParseFrom(context.Payload);
            BattleNetErrors errorCode   = (BattleNetErrors)logonResult.ErrorCode;

            if (errorCode != BattleNetErrors.ERROR_OK)
            {
                this.m_battleNet.EnqueueErrorInfo(BnetFeature.Auth, BnetFeatureEvent.Auth_OnFinish, errorCode, 0);
                return;
            }
            this.m_accountEntity = logonResult.Account;
            this.m_battleNet.Presence.PresenceSubscribe(this.m_accountEntity);
            this.m_gameAccounts = new List <bnet.protocol.EntityId>();
            foreach (bnet.protocol.EntityId gameAccountList in logonResult.GameAccountList)
            {
                this.m_gameAccounts.Add(gameAccountList);
                this.m_battleNet.Presence.PresenceSubscribe(gameAccountList);
            }
            if (logonResult.HasBattleTag)
            {
                this.m_battleTag = logonResult.BattleTag;
            }
            if (this.m_gameAccounts.Count > 0)
            {
                this.m_gameAccount = logonResult.GameAccountList[0];
            }
            this.m_sessionKey = logonResult.SessionKey;
            this.m_battleNet.IssueSelectGameAccountRequest();
            this.m_battleNet.SetConnectedRegion(logonResult.ConnectedRegion);
            base.ApiLog.LogDebug("LogonComplete {0}", new object[] { logonResult });
            base.ApiLog.LogDebug("Region (connected): {0}", new object[] { logonResult.ConnectedRegion });
        }
Exemplo n.º 5
0
        public static BnetEntityId CreateFromProtocol(bnet.protocol.EntityId src)
        {
            BnetEntityId bnetEntityId = new BnetEntityId();

            bnetEntityId.SetLo(src.Low);
            bnetEntityId.SetHi(src.High);
            return(bnetEntityId);
        }
Exemplo n.º 6
0
        private void GetAccountLevelInfo(bnet.protocol.EntityId accountId)
        {
            GetAccountStateRequest getAccountStateRequest = new GetAccountStateRequest();

            getAccountStateRequest.SetEntityId(accountId);
            AccountFieldOptions accountFieldOptions = new AccountFieldOptions();

            accountFieldOptions.SetFieldAccountLevelInfo(true);
            getAccountStateRequest.SetOptions(accountFieldOptions);
            this.m_rpcConnection.QueueRequest(this.m_accountService.Id, 30u, getAccountStateRequest, new RPCContextDelegate(this.GetAccountStateCallback), 0u);
        }
Exemplo n.º 7
0
 public bool AddFriendsActiveGameAccount(BnetEntityId entityId, bnet.protocol.EntityId gameAccount, ulong index)
 {
     if (!this.IsFriend(entityId))
     {
         return(false);
     }
     if (!this.m_friendEntityId[entityId].ContainsKey(index))
     {
         this.m_friendEntityId[entityId].Add(index, gameAccount);
         this.m_battleNet.Presence.PresenceSubscribe(gameAccount);
     }
     return(true);
 }
Exemplo n.º 8
0
        public void CreateFriendlyChallengeGame(long myDeck, long hisDeck, bnet.protocol.EntityId hisGameAccount, int scenario)
        {
            FindGameRequest findGameRequest = new FindGameRequest();
            Player          player          = new Player();
            Identity        identity        = new Identity();

            identity.SetGameAccountId(this.m_battleNet.GameAccountId);
            GameProperties  gameProperties  = new GameProperties();
            AttributeFilter attributeFilter = new AttributeFilter();

            attributeFilter.SetOp(AttributeFilter.Types.Operation.MATCH_ALL);
            if (!BattleNet.IsVersionInt())
            {
                attributeFilter.AddAttribute(ProtocolHelper.CreateAttribute("version", BattleNet.GetVersion()));
            }
            else
            {
                int num = 0;
                if (!int.TryParse(BattleNet.GetVersion(), out num))
                {
                    LogAdapter.Log(LogLevel.Error, "Could not convert BattleNetVersion to int: " + BattleNet.GetVersion());
                }
                attributeFilter.AddAttribute(ProtocolHelper.CreateAttribute("version", (long)num));
            }
            attributeFilter.AddAttribute(ProtocolHelper.CreateAttribute("GameType", 1L));
            attributeFilter.AddAttribute(ProtocolHelper.CreateAttribute("ScenarioId", (long)scenario));
            gameProperties.SetFilter(attributeFilter);
            gameProperties.AddCreationAttributes(ProtocolHelper.CreateAttribute("type", 1L));
            gameProperties.AddCreationAttributes(ProtocolHelper.CreateAttribute("scenario", (long)scenario));
            player.SetIdentity(identity);
            player.AddAttribute(ProtocolHelper.CreateAttribute("type", 1L));
            player.AddAttribute(ProtocolHelper.CreateAttribute("scenario", (long)scenario));
            player.AddAttribute(ProtocolHelper.CreateAttribute("deck", (long)((int)myDeck)));
            findGameRequest.AddPlayer(player);
            identity = new Identity();
            player   = new Player();
            identity.SetGameAccountId(hisGameAccount);
            player.SetIdentity(identity);
            player.AddAttribute(ProtocolHelper.CreateAttribute("type", 1L));
            player.AddAttribute(ProtocolHelper.CreateAttribute("scenario", (long)scenario));
            player.AddAttribute(ProtocolHelper.CreateAttribute("deck", (long)((int)hisDeck)));
            findGameRequest.AddPlayer(player);
            findGameRequest.SetProperties(gameProperties);
            findGameRequest.SetAdvancedNotification(true);
            FindGameRequest findGameRequest2 = findGameRequest;

            this.PrintFindGameRequest(findGameRequest2);
            this.IsFindGamePending = true;
            this.m_rpcConnection.QueueRequest(this.m_gameMasterService.Id, 3u, findGameRequest2, new RPCContextDelegate(this.FindGameCallback), 0u);
        }
Exemplo n.º 9
0
 public void PresenceUnsubscribe(bnet.protocol.EntityId entityId)
 {
     if (this.m_presenceSubscriptions.ContainsKey(entityId))
     {
         this.m_presenceSubscriptions[entityId].refCount--;
         if (this.m_presenceSubscriptions[entityId].refCount <= 0)
         {
             if (this.m_queuedSubscriptions.Contains(entityId))
             {
                 this.m_queuedSubscriptions.Remove(entityId);
                 return;
             }
             PresenceAPI.PresenceUnsubscribeContext @object = new PresenceAPI.PresenceUnsubscribeContext(this.m_battleNet, this.m_presenceSubscriptions[entityId].objectId);
             UnsubscribeRequest unsubscribeRequest          = new UnsubscribeRequest();
             unsubscribeRequest.SetEntityId(entityId);
             this.m_rpcConnection.QueueRequest(this.m_presenceService.Id, 2u, unsubscribeRequest, new RPCContextDelegate(@object.PresenceUnsubscribeCallback), 0u);
             this.m_presenceSubscriptions.Remove(entityId);
         }
     }
 }
Exemplo n.º 10
0
        public void RequestPresenceFields(bool isGameAccountEntityId, [In] bgs.types.EntityId entityId, [In] PresenceFieldKey[] fieldList)
        {
            QueryRequest queryRequest = new QueryRequest();

            bnet.protocol.EntityId entityId1 = new bnet.protocol.EntityId();
            entityId1.SetHigh(entityId.hi);
            entityId1.SetLow(entityId.lo);
            queryRequest.SetEntityId(entityId1);
            PresenceFieldKey[] presenceFieldKeyArray = fieldList;
            for (int i = 0; i < (int)presenceFieldKeyArray.Length; i++)
            {
                PresenceFieldKey presenceFieldKey = presenceFieldKeyArray[i];
                FieldKey         fieldKey         = new FieldKey();
                fieldKey.SetProgram(presenceFieldKey.programId);
                fieldKey.SetGroup(presenceFieldKey.groupId);
                fieldKey.SetField(presenceFieldKey.fieldId);
                fieldKey.SetIndex(presenceFieldKey.index);
                queryRequest.AddKey(fieldKey);
            }
            this.m_rpcConnection.QueueRequest(this.m_presenceService.Id, 4, queryRequest, (RPCContext context) => this.RequestPresenceFieldsCallback(new bgs.types.EntityId(entityId), context), 0);
        }
        private void HandleLogonCompleteRequest(RPCContext context)
        {
            byte[]          payload     = context.Payload;
            LogonResult     logonResult = LogonResult.ParseFrom(payload);
            BattleNetErrors errorCode   = (BattleNetErrors)logonResult.ErrorCode;

            if (errorCode != BattleNetErrors.ERROR_OK)
            {
                this.m_battleNet.EnqueueErrorInfo(BnetFeature.Auth, BnetFeatureEvent.Auth_OnFinish, errorCode, 0);
                return;
            }
            this.m_accountEntity = logonResult.Account;
            this.m_battleNet.Presence.PresenceSubscribe(this.m_accountEntity);
            this.m_gameAccounts = new List <bnet.protocol.EntityId>();
            using (List <bnet.protocol.EntityId> .Enumerator enumerator = logonResult.GameAccountList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    bnet.protocol.EntityId current = enumerator.get_Current();
                    this.m_gameAccounts.Add(current);
                    this.m_battleNet.Presence.PresenceSubscribe(current);
                }
            }
            if (this.m_gameAccounts.get_Count() > 0)
            {
                this.m_gameAccount = logonResult.GameAccountList.get_Item(0);
            }
            this.m_sessionKey = logonResult.SessionKey;
            this.m_battleNet.IssueSelectGameAccountRequest();
            this.m_battleNet.SetConnectedRegion(logonResult.ConnectedRegion);
            base.ApiLog.LogDebug("LogonComplete {0}", new object[]
            {
                logonResult
            });
            base.ApiLog.LogDebug("Region (connected): {0}", new object[]
            {
                logonResult.ConnectedRegion
            });
        }
Exemplo n.º 12
0
        public void RemoveFriend(BnetAccountId account)
        {
            if (this.m_state != FriendsAPI.FriendsAPIState.INITIALIZED)
            {
                return;
            }
            bnet.protocol.EntityId entityId = new bnet.protocol.EntityId();
            entityId.SetLow(account.GetLo());
            entityId.SetHigh(account.GetHi());
            GenericFriendRequest genericFriendRequest = new GenericFriendRequest();

            genericFriendRequest.SetTargetId(entityId);
            GenericFriendRequest genericFriendRequest1 = genericFriendRequest;

            if (!genericFriendRequest1.IsInitialized)
            {
                base.ApiLog.LogWarning("Battle.net Friends API C#: Failed to RemoveFriend.");
                this.m_battleNet.EnqueueErrorInfo(BnetFeature.Friends, BnetFeatureEvent.Friends_OnRemoveFriend, BattleNetErrors.ERROR_API_NOT_READY, 0);
                return;
            }
            this.m_rpcConnection.QueueRequest(this.m_friendsService.Id, 8, genericFriendRequest1, new RPCContextDelegate(this.RemoveFriendCallback), 0);
        }
Exemplo n.º 13
0
        public void RequestPresenceFields(bool isGameAccountEntityId, [In] bgs.types.EntityId entityId, [In] PresenceFieldKey[] fieldList)
        {
            QueryRequest queryRequest = new QueryRequest();

            bnet.protocol.EntityId entityId2 = new bnet.protocol.EntityId();
            entityId2.SetHigh(entityId.hi);
            entityId2.SetLow(entityId.lo);
            queryRequest.SetEntityId(entityId2);
            foreach (PresenceFieldKey presenceFieldKey in fieldList)
            {
                FieldKey fieldKey = new FieldKey();
                fieldKey.SetProgram(presenceFieldKey.programId);
                fieldKey.SetGroup(presenceFieldKey.groupId);
                fieldKey.SetField(presenceFieldKey.fieldId);
                fieldKey.SetIndex(presenceFieldKey.index);
                queryRequest.AddKey(fieldKey);
            }
            this.m_rpcConnection.QueueRequest(this.m_presenceService.Id, 4u, queryRequest, delegate(RPCContext context)
            {
                this.RequestPresenceFieldsCallback(new bgs.types.EntityId(entityId), context);
            }, 0u);
        }
Exemplo n.º 14
0
 private void HandleSubscriptionRequests()
 {
     if (this.m_queuedSubscriptions.get_Count() > 0)
     {
         long elapsedMilliseconds = this.m_stopWatch.get_ElapsedMilliseconds();
         this.m_presenceSubscriptionBalance  = Math.Min(0f, this.m_presenceSubscriptionBalance + (float)(elapsedMilliseconds - this.m_lastPresenceSubscriptionSent) * 0.00333333341f);
         this.m_lastPresenceSubscriptionSent = elapsedMilliseconds;
         List <bnet.protocol.EntityId> list = new List <bnet.protocol.EntityId>();
         using (HashSet <bnet.protocol.EntityId> .Enumerator enumerator = this.m_queuedSubscriptions.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 bnet.protocol.EntityId current = enumerator.get_Current();
                 if (this.m_presenceSubscriptionBalance - 1f < -100f)
                 {
                     break;
                 }
                 PresenceAPI.PresenceRefCountObject presenceRefCountObject = this.m_presenceSubscriptions[current];
                 SubscribeRequest subscribeRequest = new SubscribeRequest();
                 subscribeRequest.SetObjectId(ChannelAPI.GetNextObjectId());
                 subscribeRequest.SetEntityId(current);
                 presenceRefCountObject.objectId = subscribeRequest.ObjectId;
                 this.m_battleNet.Channel.AddActiveChannel(subscribeRequest.ObjectId, new ChannelAPI.ChannelReferenceObject(current, ChannelAPI.ChannelType.PRESENCE_CHANNEL));
                 this.m_rpcConnection.QueueRequest(this.m_presenceService.Id, 1u, subscribeRequest, new RPCContextDelegate(this.PresenceSubscribeCallback), 0u);
                 this.m_presenceSubscriptionBalance -= 1f;
                 list.Add(current);
             }
         }
         using (List <bnet.protocol.EntityId> .Enumerator enumerator2 = list.GetEnumerator())
         {
             while (enumerator2.MoveNext())
             {
                 bnet.protocol.EntityId current2 = enumerator2.get_Current();
                 this.m_queuedSubscriptions.Remove(current2);
             }
         }
     }
 }
Exemplo n.º 15
0
        public void SendFriendInvite(string sender, string target, bool byEmail)
        {
            if (this.m_state != FriendsAPI.FriendsAPIState.INITIALIZED)
            {
                return;
            }
            SendInvitationRequest sendInvitationRequest = new SendInvitationRequest();

            bnet.protocol.EntityId entityId = new bnet.protocol.EntityId();
            entityId.SetLow((ulong)0);
            entityId.SetHigh((ulong)0);
            sendInvitationRequest.SetTargetId(entityId);
            InvitationParams       invitationParam       = new InvitationParams();
            FriendInvitationParams friendInvitationParam = new FriendInvitationParams();

            if (!byEmail)
            {
                friendInvitationParam.SetTargetBattleTag(target);
                friendInvitationParam.AddRole(1);
            }
            else
            {
                friendInvitationParam.SetTargetEmail(target);
                friendInvitationParam.AddRole(2);
            }
            invitationParam.SetFriendParams(friendInvitationParam);
            sendInvitationRequest.SetParams(invitationParam);
            SendInvitationRequest sendInvitationRequest1 = sendInvitationRequest;

            if (!sendInvitationRequest1.IsInitialized)
            {
                base.ApiLog.LogWarning("Battle.net Friends API C#: Failed to SendFriendInvite.");
                return;
            }
            this.m_rpcConnection.QueueRequest(this.m_friendsService.Id, 2, sendInvitationRequest1, new RPCContextDelegate(this.SendInvitationCallback), 0);
        }
Exemplo n.º 16
0
 public void SetEntityId(bnet.protocol.EntityId val)
 {
     this.EntityId = val;
 }
        public override bool Equals(object obj)
        {
            EntityId entityId = obj as EntityId;

            return(entityId != null && this.High.Equals(entityId.High) && this.Low.Equals(entityId.Low));
        }
 public void Deserialize(Stream stream)
 {
     EntityId.Deserialize(stream, this);
 }
 public static EntityId Deserialize(Stream stream, EntityId instance)
 {
     return(EntityId.Deserialize(stream, instance, -1L));
 }
Exemplo n.º 20
0
 public void SetAccountId(EntityId val)
 {
     this.AccountId = val;
 }
Exemplo n.º 21
0
		public static PartyId FromProtocol(bnet.protocol.EntityId protoEntityId)
		{
			return new PartyId(protoEntityId.High, protoEntityId.Low);
		}
Exemplo n.º 22
0
 public void SetGameAccountId(EntityId val)
 {
     this.GameAccountId = val;
 }
 public EntityId(bnet.protocol.EntityId protoEntityId)
 {
     this.hi = protoEntityId.High;
     this.lo = protoEntityId.Low;
 }
Exemplo n.º 24
0
 public void PresenceSubscribe(bnet.protocol.EntityId entityId)
 {
 }
 public void Serialize(Stream stream)
 {
     EntityId.Serialize(stream, this);
 }