public void MatchMakerEndHandler(bnet.protocol.notification.Notification notification)
    {
        BattleNetErrors errors = (BattleNetErrors)((uint)ProtocolHelper.GetUintAttribute(notification.AttributeList, "error", 0L, null));
        ulong           num    = ProtocolHelper.GetUintAttribute(notification.AttributeList, "game_request_id", 0L, null);

        object[] args = new object[] { num, (uint)errors };
        base.ApiLog.LogDebug("MM_END requestId={0} code={1}", args);
        BattleNet.QueueEvent.Type queueType = BattleNet.QueueEvent.Type.QUEUE_LEAVE;
        switch (errors)
        {
        case BattleNetErrors.ERROR_OK:
            queueType = BattleNet.QueueEvent.Type.QUEUE_LEAVE;
            break;

        case BattleNetErrors.ERROR_GAME_MASTER_GAME_ENTRY_CANCELLED:
            queueType = BattleNet.QueueEvent.Type.QUEUE_CANCEL;
            break;

        case BattleNetErrors.ERROR_GAME_MASTER_GAME_ENTRY_ABORTED_CLIENT_DROPPED:
            queueType = BattleNet.QueueEvent.Type.ABORT_CLIENT_DROPPED;
            break;

        default:
            queueType = BattleNet.QueueEvent.Type.QUEUE_AMM_ERROR;
            break;
        }
        object[] objArray2 = new object[] { queueType, (uint)errors };
        base.ApiLog.LogDebug("MatchMakerEndHandler event={0} code={1}", objArray2);
        this.AddQueueEvent(queueType, 0, 0, (int)errors, null);
    }
 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);
     }
 }
Example #3
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);
             }
         }
     }
 }
    public void QueueExitHandler(bnet.protocol.notification.Notification notification)
    {
        BattleNetErrors errors = (BattleNetErrors)((uint)ProtocolHelper.GetUintAttribute(notification.AttributeList, "error", 0L, null));
        ulong           num    = ProtocolHelper.GetUintAttribute(notification.AttributeList, "game_request_id", 0L, null);

        object[] args = new object[] { num, (uint)errors };
        base.ApiLog.LogDebug("QueueExitHandler: requestId={0} code={1}", args);
        if (errors != BattleNetErrors.ERROR_OK)
        {
            BattleNet.QueueEvent.Type queueType = BattleNet.QueueEvent.Type.QUEUE_DELAY_ERROR;
            object[] objArray2 = new object[] { queueType, (uint)errors };
            base.ApiLog.LogDebug("QueueExitHandler event={0} code={1}", objArray2);
            this.AddQueueEvent(queueType, 0, 0, (int)errors, null);
        }
    }
    private void QueueUpdate(BattleNet.QueueEvent.Type queueType, bnet.protocol.notification.Notification notification)
    {
        int minSeconds = 0;
        int maxSeconds = 0;

        foreach (bnet.protocol.attribute.Attribute attribute in notification.AttributeList)
        {
            if ((attribute.Name == "min_wait") && attribute.Value.HasUintValue)
            {
                minSeconds = (int)attribute.Value.UintValue;
            }
            else if ((attribute.Name == "max_wait") && attribute.Value.HasUintValue)
            {
                maxSeconds = (int)attribute.Value.UintValue;
            }
        }
        this.AddQueueEvent(queueType, minSeconds, maxSeconds, 0, null);
    }
 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);
         }
     }
 }
 public void QueueUpdateHandler(bnet.protocol.notification.Notification notification)
 {
     base.ApiLog.LogDebug("QueueUpdateHandler: " + notification);
     this.QueueUpdate(BattleNet.QueueEvent.Type.QUEUE_UPDATE, notification);
 }
 public void MatchMakerStartHandler(bnet.protocol.notification.Notification notification)
 {
     base.ApiLog.LogDebug("MM_START");
     this.AddQueueEvent(BattleNet.QueueEvent.Type.QUEUE_ENTER, 0, 0, 0, null);
 }
    public void GameEntryHandler(bnet.protocol.notification.Notification notification)
    {
        base.ApiLog.LogDebug("GAME_ENTRY");
        string host        = null;
        int    port        = 0;
        string stringValue = null;
        int    intValue    = 0;
        int    num3        = 0;
        string str3        = null;
        bool   boolValue   = false;
        string str4        = null;

        foreach (bnet.protocol.attribute.Attribute attribute in notification.AttributeList)
        {
            if (attribute.Name.Equals("connection_info") && attribute.Value.HasMessageValue)
            {
                ConnectInfo info = ConnectInfo.ParseFrom(attribute.Value.MessageValue);
                host = info.Host;
                port = info.Port;
                if (info.HasToken)
                {
                    str3 = Encoding.UTF8.GetString(info.Token);
                }
                foreach (bnet.protocol.attribute.Attribute attribute2 in info.AttributeList)
                {
                    if (attribute2.Name.Equals("version") && attribute2.Value.HasStringValue)
                    {
                        stringValue = attribute2.Value.StringValue;
                    }
                    else if (attribute2.Name.Equals("game") && attribute2.Value.HasIntValue)
                    {
                        intValue = (int)attribute2.Value.IntValue;
                    }
                    else if (attribute2.Name.Equals("id") && attribute2.Value.HasIntValue)
                    {
                        num3 = (int)attribute2.Value.IntValue;
                    }
                    else if (attribute2.Name.Equals("resumable") && attribute2.Value.HasBoolValue)
                    {
                        boolValue = attribute2.Value.BoolValue;
                    }
                    else if (attribute2.Name.Equals("spectator_password") && attribute2.Value.HasStringValue)
                    {
                        str4 = attribute2.Value.StringValue;
                    }
                }
            }
            else if (attribute.Name.Equals("game_handle") && attribute.Value.HasMessageValue)
            {
                GameHandle handle = GameHandle.ParseFrom(attribute.Value.MessageValue);
                base.m_battleNet.Channel.JoinChannel(handle.GameId, ChannelAPI.ChannelType.GAME_CHANNEL);
            }
            else if (attribute.Name.Equals("sender_id") && attribute.Value.HasMessageValue)
            {
                base.ApiLog.LogDebug("sender_id");
            }
        }
        BattleNet.GameServerInfo gsInfo = new BattleNet.GameServerInfo {
            Address           = host,
            Port              = port,
            AuroraPassword    = str3,
            Version           = stringValue,
            GameHandle        = intValue,
            ClientHandle      = num3,
            Resumable         = boolValue,
            SpectatorPassword = str4
        };
        this.AddQueueEvent(BattleNet.QueueEvent.Type.QUEUE_GAME_STARTED, 0, 0, 0, gsInfo);
    }