Beispiel #1
0
        private void OnConnectCallback(RPCContext context)
        {
            BattleNetErrors status = (BattleNetErrors)context.Header.Status;

            this.m_logSource.LogDebug("RPC Connected, error : " + status.ToString());
            if (status != BattleNetErrors.ERROR_OK)
            {
                this.SwitchToState(BattleNetCSharp.ConnectionState.Error);
                this.EnqueueErrorInfo(BnetFeature.Bnet, BnetFeatureEvent.Bnet_OnConnected, status, 0);
                return;
            }
            ConnectResponse connectResponse = ConnectResponse.ParseFrom(context.Payload);

            if (connectResponse.HasServerTime)
            {
                this.m_serverTimeUTCAtConnectMicroseconds = (long)connectResponse.ServerTime;
                this.m_serverTimeDeltaUTCSeconds          = this.m_serverTimeUTCAtConnectMicroseconds / 1000000L - this.GetCurrentTimeSecondsSinceUnixEpoch();
            }
            if (connectResponse.HasBindResult && connectResponse.HasBindResponse && connectResponse.BindResult == 0u)
            {
                int num = 0;
                foreach (uint num2 in connectResponse.BindResponse.ImportedServiceIdList)
                {
                    ServiceDescriptor serviceDescriptor = this.m_importedServices[num++];
                    serviceDescriptor.Id = num2;
                    this.m_rpcConnection.serviceHelper.AddImportedService(num2, serviceDescriptor);
                    this.m_logSource.LogDebug("Importing service id={0} name={1}", new object[]
                    {
                        serviceDescriptor.Id,
                        serviceDescriptor.Name
                    });
                }
                this.m_logSource.LogDebug("FRONT ServerId={0:x2}", new object[]
                {
                    connectResponse.ServerId.Label
                });
                this.InitRPCListeners();
                this.PrintBindServiceResponse(connectResponse.BindResponse);
                this.SwitchToState(BattleNetCSharp.ConnectionState.Logon);
                return;
            }
            this.m_logSource.LogWarning("BindRequest failed with error={0}", new object[]
            {
                connectResponse.BindResult
            });
            this.SwitchToState(BattleNetCSharp.ConnectionState.Error);
        }