Пример #1
0
        public void Execute(HttpRequest httpRequest, JsonPacket jsonRequest)
        {
            // Connect
            NetworkChannel channel = new NetworkChannel(Connection);

            // Request
            JsonPingRequestMessage jsonRequestMessage = JsonPingRequestMessage.Parse(jsonRequest.Message);

            // Response
            JsonPingResponseMessage jsonResponseMessage = new JsonPingResponseMessage();
            JsonPacket jsonResponse = new JsonPacket(jsonResponseMessage);

            HttpResponse httpResponse = new HttpResponse()
            {
                Data = Session.Encrypt(jsonResponse)
            };

            channel.Send(httpResponse);
#if DEBUG
            Log.Add(httpRequest, httpResponse, jsonRequest, jsonResponse);
#endif
        }
Пример #2
0
        public void Execute(HttpRequest httpRequest, JsonPacket jsonRequest, SessionComponent session)
        {
            // Connect
            NetworkChannel channel = new NetworkChannel(Connection);

            // Request
            JsonPingRequestMessage jsonRequestMessage = JsonPingRequestMessage.Parse(jsonRequest.Message);

            // Data
            HttpCode        code   = HttpCode.Ok;
            Entity          entity = session.Owner;
            TunnelComponent tunnel = entity.Get <TunnelComponent>();

            if (tunnel != null)
            {
                PingRequestCommand command = new PingRequestCommand(entity, tunnel.Connection);
                code = command.Execute();
                if (code == HttpCode.Ok)
                {
                    entity.Update();
                }
            }

            // Response
            JsonPingResponseMessage jsonResponseMessage = new JsonPingResponseMessage();
            JsonPacket jsonResponse = new JsonPacket(jsonResponseMessage);

            HttpResponse httpResponse = new HttpResponse(code)
            {
                Data = session.Encrypt(jsonResponse)
            };

            channel.Send(httpResponse);
#if DEBUG
            Log.Add(httpRequest, httpResponse, jsonRequest, jsonResponse);
#endif
        }