Ejemplo n.º 1
0
        public override void ModuleMessage(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.authentication.ModuleMessageRequest request, Action <bnet.protocol.NoData> done)
        {
            var moduleMessage = request.Message.ToByteArray();
            var command       = moduleMessage[0];
            var module        = this.Client.ClientModuleIds.Where(pair => pair.Value == request.ModuleId).Select(pair => pair.Key).First();

            Logger.Trace("ModuleMessage(): Module: {0} ModuleId: {1} Command: {2}", module, request.ModuleId, command);

            done(bnet.protocol.NoData.CreateBuilder().Build());

            switch (module)
            {
            case MooNetClient.StreamedModule.Password:
                if (command == 2)
                {
                    AuthManager.HandleAuthResponse(this.Client, request.ModuleId, moduleMessage);
                }
                else
                {
                    Logger.Error("Unknown command: {0} for Password module.", command);
                }
                break;

            case MooNetClient.StreamedModule.Token:

                var moduleLoadRequest = bnet.protocol.authentication.ModuleLoadRequest.CreateBuilder();
                var moduleHandle      = bnet.protocol.ContentHandle.CreateBuilder();
                moduleHandle.SetRegion(VersionInfo.MooNet.Regions[VersionInfo.MooNet.Region])
                .SetUsage(0x61757468);         // auth - RiskFingerprint.dll or Agreement.dll

                if (this.Client.HasAgreements())
                {
                    moduleHandle.SetHash(ByteString.CopyFrom(VersionInfo.MooNet.AgreementHashMap[this.Client.Platform]));
                    this.Client.LastRequestedModule = MooNetClient.StreamedModule.Agreement;
                }
                else
                {
                    moduleHandle.SetHash(ByteString.CopyFrom(VersionInfo.MooNet.RiskFingerprintHashMap[this.Client.Platform]));
                    moduleLoadRequest.SetMessage(ByteString.Empty);
                    this.Client.LastRequestedModule = MooNetClient.StreamedModule.RiskFingerprint;
                }

                moduleLoadRequest.SetModuleHandle(moduleHandle);
                this.Client.MakeRPC(() => bnet.protocol.authentication.AuthenticationClient.CreateStub(this.Client).ModuleLoad(null, moduleLoadRequest.Build(), ModuleLoadResponse));
                break;

            case MooNetClient.StreamedModule.RiskFingerprint:
                Logger.Trace("Completing Authentication.");
                this.Client.AuthenticationComplete();
                break;

            case MooNetClient.StreamedModule.Agreement:
                switch (this.Client.LastAgreementSent)
                {
                case MooNetClient.AvailableAgreements.EULA:
                    this.Client.Agreements.Add(MooNetClient.AvailableAgreements.EULA, true);
                    break;

                case MooNetClient.AvailableAgreements.TOS:
                    this.Client.Agreements.Add(MooNetClient.AvailableAgreements.TOS, true);
                    break;

                case MooNetClient.AvailableAgreements.RMAH:
                    this.Client.Agreements.Add(MooNetClient.AvailableAgreements.RMAH, true);
                    break;

                default:
                    Logger.Error("Unknown agreement.");
                    break;
                }
                this.Client.SendAgreements();
                break;

            default:
                Logger.Error("Unknown module message data.");
                break;
            }
        }
Ejemplo n.º 2
0
        public override void ModuleMessage(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.authentication.ModuleMessageRequest request, Action <bnet.protocol.NoData> done)
        {
            var moduleMessage = request.Message.ToByteArray();
            var command       = moduleMessage[0];

            Logger.Trace("ModuleMessage(): command: {0}", command);

            done(bnet.protocol.NoData.CreateBuilder().Build());

            if (command == 2)
            {
                AuthManager.HandleAuthResponse(this.Client, request.ModuleId, moduleMessage);
            }
        }