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);
 }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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.º 6
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.º 7
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);
        }