Exemplo n.º 1
0
 private void StartGame(GameType gameType, ReconnectType reconnectType, BattleNet.GameServerInfo serverInfo)
 {
     this.m_savedStartGameParams.GameType      = gameType;
     this.m_savedStartGameParams.ReconnectType = reconnectType;
     this.m_savedStartGameParams.ServerInfo    = serverInfo;
     this.StartGame();
 }
    private void ResolveAddressAndGotoGameServer(BattleNet.GameServerInfo gameServer)
    {
        IPAddress address;

        if (IPAddress.TryParse(gameServer.Address, out address))
        {
            gameServer.Address = address.ToString();
            Network.Get().GotoGameServer(gameServer, false);
        }
        else
        {
            try
            {
                foreach (IPAddress address2 in Dns.GetHostEntry(gameServer.Address).AddressList)
                {
                    gameServer.Address = address2.ToString();
                    Network.Get().GotoGameServer(gameServer, false);
                    return;
                }
            }
            catch (Exception exception)
            {
                base.m_logSource.LogError("Exception within ResolveAddressAndGotoGameServer: " + exception.Message);
            }
            this.ThrowDnsResolveError(gameServer.Address);
        }
    }
Exemplo n.º 3
0
 public QueueEvent(Type t, int minSeconds, int maxSeconds, int bnetError, BattleNet.GameServerInfo gsInfo)
 {
     this.EventType  = t;
     this.MinSeconds = minSeconds;
     this.MaxSeconds = maxSeconds;
     this.BnetError  = bnetError;
     this.GameServer = gsInfo;
 }
 private void GoToNoAccountTutorialServer(int scenario)
 {
     BattleNet.GameServerInfo gameServer = new BattleNet.GameServerInfo();
     if (!BattleNet.IsVersionInt() && (BattleNet.GetVersionString() == "PAX"))
     {
         gameServer.Version = BattleNet.GetVersionString() + BattleNet.GetVersionInt().ToString();
     }
     else
     {
         gameServer.Version = BattleNet.GetVersion();
     }
     if (Vars.Key("Loopback.Active").GetBool(false))
     {
         gameServer.Address        = Vars.Key("Loopback.Address").GetStr(string.Empty);
         gameServer.Port           = Vars.Key("Loopback.Port").GetInt(0);
         gameServer.AuroraPassword = BattleNet.GetVersionString();
     }
     else
     {
         Network.BnetRegion currentRegionId = MobileDeviceLocale.GetCurrentRegionId();
         if (ApplicationMgr.GetMobileEnvironment() == MobileEnv.PRODUCTION)
         {
             string str;
             try
             {
                 str = RegionToTutorialName[currentRegionId];
             }
             catch (KeyNotFoundException)
             {
                 Debug.LogWarning("No matching tutorial server name found for region " + currentRegionId);
                 str = "us";
             }
             gameServer.Address = string.Format("{0}-tutorial{1}.actual.battle.net", str, BattleNet.TutorialServer);
             gameServer.Port    = 0x45f;
         }
         else
         {
             gameServer.Address = "10.130.126.28";
             MobileDeviceLocale.ConnectionData connectionDataFromRegionId = MobileDeviceLocale.GetConnectionDataFromRegionId(currentRegionId, true);
             gameServer.Port    = connectionDataFromRegionId.tutorialPort;
             gameServer.Version = connectionDataFromRegionId.version;
         }
         object[] args = new object[] { currentRegionId, gameServer.Address, gameServer.Port, gameServer.Version };
         Log.JMac.Print(string.Format("Connecting to account-free tutorial server for region {0}.  Address: {1}  Port: {2}  Version: {3}", args), new object[0]);
         gameServer.AuroraPassword = string.Empty;
     }
     gameServer.GameHandle   = 0;
     gameServer.ClientHandle = 0L;
     gameServer.Mission      = scenario;
     this.ResolveAddressAndGotoGameServer(gameServer);
 }
Exemplo n.º 5
0
    public bool ReconnectFromGameplay()
    {
        if (!this.IsReconnectEnabled())
        {
            return(false);
        }
        BattleNet.GameServerInfo lastGameServerJoined = Network.Get().GetLastGameServerJoined();
        if (lastGameServerJoined == null)
        {
            Debug.LogError("serverInfo in ReconnectMgr.ReconnectFromGameplay is null and should not be!");
            return(false);
        }
        if (!lastGameServerJoined.Resumable)
        {
            return(false);
        }
        this.HideDialog();
        GameType      gameType = GameMgr.Get().GetGameType();
        ReconnectType gAMEPLAY = ReconnectType.GAMEPLAY;

        this.StartReconnecting(gAMEPLAY);
        this.StartGame(gameType, gAMEPLAY, lastGameServerJoined);
        return(true);
    }
    private void AddQueueEvent(BattleNet.QueueEvent.Type queueType, int minSeconds = 0, int maxSeconds = 0, int bnetError = 0, BattleNet.GameServerInfo gsInfo = null)
    {
        BattleNet.QueueEvent         item        = new BattleNet.QueueEvent(queueType, minSeconds, maxSeconds, bnetError, gsInfo);
        Queue <BattleNet.QueueEvent> queueEvents = this.m_queueEvents;

        lock (queueEvents)
        {
            this.m_queueEvents.Enqueue(item);
        }
    }
    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);
    }