Ejemplo n.º 1
0
        private void HandleForceDisconnectRequest(RPCContext context)
        {
            DisconnectNotification disconnectNotification = DisconnectNotification.ParseFrom(context.Payload);

            this.m_logSource.LogDebug("RPC Called: ForceDisconnect : " + disconnectNotification.ErrorCode);
            this.EnqueueErrorInfo(BnetFeature.Bnet, BnetFeatureEvent.Bnet_OnDisconnected, (BattleNetErrors)disconnectNotification.ErrorCode, 0);
        }
Ejemplo n.º 2
0
        BattlenetRpcErrorCode HandleRequestDisconnect(DisconnectRequest request)
        {
            var disconnectNotification = new DisconnectNotification();

            disconnectNotification.ErrorCode = request.ErrorCode;
            SendRequest((uint)OriginalHash.ConnectionService, 4, disconnectNotification);

            CloseSocket();
            return(BattlenetRpcErrorCode.Ok);
        }
Ejemplo n.º 3
0
        BattlenetRpcErrorCode HandleRequestDisconnect(DisconnectRequest request)
        {
            var disconnectNotification = new DisconnectNotification();

            disconnectNotification.ErrorCode = request.ErrorCode;
            SendRequest(4, disconnectNotification);

            _session.CloseSocket();
            return(BattlenetRpcErrorCode.Ok);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Executes the operation's logic.
        /// </summary>
        /// <param name="context">A reference to the operation context.</param>
        protected override void Execute(IOperationContext context)
        {
            var targetLoginLocation = this.playerMetadata.LastLocation;

            if (context.Map[targetLoginLocation] == null)
            {
                targetLoginLocation = this.playerMetadata.StartingLocation;
            }

            var creationArguments = new PlayerCreationArguments()
            {
                Type          = CreatureType.Player,
                Metadata      = this.playerMetadata,
                PreselectedId = this.preselectedPlayerId,
            };

            if (!(context.CreatureFactory.CreateCreature(creationArguments) is IPlayer player))
            {
                context.Logger.LogWarning($"Unable to create player instance for {this.playerMetadata.Name}, aborting log in.");

                return;
            }

            if (!context.GameApi.AddCreatureToGame(targetLoginLocation, player))
            {
                // Unable to place the player in the map.
                var disconnectNotification = new DisconnectNotification(
                    player.YieldSingleItem(),
                    "Your character could not be placed on the map.\nPlease try again, or contact an administrator if the issue persists.");

                context.GameApi.SendNotification(disconnectNotification);

                return;
            }

            var descriptionTiles = context.Map.DescribeAt(player, player.Location);

            // TODO: In addition, we need to send the player's inventory, the first time login message + outfit window here if applicable.
            // And any VIP records here.
            this.SendNotification(context, new PlayerLoginNotification(player, player.Location, descriptionTiles, AnimatedEffect.BubbleBlue));
            this.SendNotification(context, new WorldLightChangedNotification(player.YieldSingleItem(), this.currentWorldLightLevel, this.currentWorldLightColor));
            this.SendNotification(context, new CreatureLightUpdateNotification(player.YieldSingleItem(), player));
            this.SendNotification(context, new TextMessageNotification(player.YieldSingleItem(), MessageType.Status, "This is a test message"));
        }
Ejemplo n.º 5
0
        private void Handle(CodedInputStream stream)
        {
            var packet = new ClientPacket(stream);

            if (packet.Service == PrevService)
            {
                //packet.Method should be 0, if there is no errors
                Callback callback = callbacks.Dequeue();
                if (callback.RequestId != packet.RequestId)
                {
                    throw new InvalidOperationException("Callback does not match!");
                }
                callback.Action(packet.ReadMessage(callback.Builder));
                return;
            }

            IService service = importedServices[packet.Service];

            MethodDescriptor method = service.DescriptorForType.Methods.Single(m => GetMethodId(m) == packet.Method);

            Action <IMessage> done =
                response =>
            {
                ServerPacket data = new ServerPacket(PrevService, (int)ErrorCode, packet.RequestId, 0).WriteMessage(response);
                Send(data);
                if (ErrorCode != AuthError.None)
                {
                    DisconnectNotification dcNotify = DisconnectNotification.CreateBuilder().SetErrorCode((uint)ErrorCode).Build();
                    ConnectionService.CreateStub(this).ForceDisconnect(null, dcNotify, r => { });
                    Disconnect();
                }
            };

            IMessage requestProto = service.GetRequestPrototype(method);

            IMessage message = packet.ReadMessage(requestProto.WeakToBuilder());

            // Logging
            Console.WriteLine(requestProto.GetType());
            Console.WriteLine("Text View:");
            Console.WriteLine(message.ToString());

            service.CallMethod(method, null, message, done);
        }
Ejemplo n.º 6
0
 public override void ForceDisconnect(Google.ProtocolBuffers.IRpcController controller, DisconnectNotification request, Action<NO_RESPONSE> done)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 7
0
 public override void ForceDisconnect(IRpcController controller, DisconnectNotification request, Action<NO_RESPONSE> done)
 {
     ProtoOutputBuffer.Write(request.GetType(), request.ToString());
 }
Ejemplo n.º 8
0
 public override void ForceDisconnect(IRpcController controller, DisconnectNotification request, Action <NO_RESPONSE> done)
 {
     ProtoOutputBuffer.Write(request.GetType(), request.ToString());
 }
Ejemplo n.º 9
0
        public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
        {
            switch (methodId)
            {
            case 1:
            {
                ConnectRequest  request  = ConnectRequest.Parser.ParseFrom(stream);
                ConnectResponse response = new ConnectResponse();

                BattlenetRpcErrorCode status = HandleConnect(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.Connect(bgs.protocol.connection.v1.ConnectRequest: {1}) returned bgs.protocol.connection.v1.ConnectResponse: {2} status: {3}.",
                             GetCallerInfo(), request.ToString(), response.ToString(), status);
                if (status == 0)
                {
                    SendResponse(token, response);
                }
                else
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 2:
            {
                BindRequest request = new BindRequest();
                request.MergeFrom(stream);

                BindResponse          response = new BindResponse();
                BattlenetRpcErrorCode status   = HandleBind(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.Bind(bgs.protocol.connection.v1.BindRequest: {1}) returned bgs.protocol.connection.v1.BindResponse: {2} status: {3}.",
                             GetCallerInfo(), request.ToString(), response.ToString(), status);
                if (status == 0)
                {
                    SendResponse(token, response);
                }
                else
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 3:
            {
                EchoRequest request = new EchoRequest();
                request.MergeFrom(stream);

                EchoResponse          response = new EchoResponse();
                BattlenetRpcErrorCode status   = HandleEcho(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.Echo(bgs.protocol.connection.v1.EchoRequest: {1}) returned bgs.protocol.connection.v1.EchoResponse: {2} status: {3}.",
                             GetCallerInfo(), request.ToString(), response.ToString(), status);
                if (status == 0)
                {
                    SendResponse(token, response);
                }
                else
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 4:
            {
                DisconnectNotification request = DisconnectNotification.Parser.ParseFrom(stream);

                BattlenetRpcErrorCode status = HandleForceDisconnect(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.ForceDisconnect(bgs.protocol.connection.v1.DisconnectNotification: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 5:
            {
                NoData request = NoData.Parser.ParseFrom(stream);

                BattlenetRpcErrorCode status = HandleKeepAlive(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.KeepAlive(bgs.protocol.NoData: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 6:
            {
                EncryptRequest request = EncryptRequest.Parser.ParseFrom(stream);

                NoData response = new NoData();
                BattlenetRpcErrorCode status = HandleEncrypt(request, response);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.Encrypt(bgs.protocol.connection.v1.EncryptRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
                             GetCallerInfo(), request.ToString(), response.ToString(), status);
                if (status == 0)
                {
                    SendResponse(token, response);
                }
                else
                {
                    SendResponse(token, status);
                }
                break;
            }

            case 7:
            {
                DisconnectRequest request = DisconnectRequest.Parser.ParseFrom(stream);

                BattlenetRpcErrorCode status = HandleRequestDisconnect(request);
                Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.RequestDisconnect(bgs.protocol.connection.v1.DisconnectRequest: {1}) status: {2}.",
                             GetCallerInfo(), request.ToString(), status);
                if (status != 0)
                {
                    SendResponse(token, status);
                }
                break;
            }

            default:
                Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
                SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
                break;
            }
        }
Ejemplo n.º 10
0
 BattlenetRpcErrorCode HandleForceDisconnect(DisconnectNotification request)
 {
     Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ConnectionService.ForceDisconnect: {1}", GetCallerInfo(), request.ToString());
     return(BattlenetRpcErrorCode.RpcNotImplemented);
 }
Ejemplo n.º 11
0
		public override void ForceDisconnect(IRpcController controller, DisconnectNotification request, Action<bnet.protocol.NO_RESPONSE> done) {
			throw new NotImplementedException();
		}
Ejemplo n.º 12
0
 public override void ForceDisconnect(Google.ProtocolBuffers.IRpcController controller, DisconnectNotification request, Action <NO_RESPONSE> done)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 13
0
 public override void ForceDisconnect(IRpcController controller, DisconnectNotification request, Action <bnet.protocol.NO_RESPONSE> done)
 {
     throw new NotImplementedException();
 }