Example #1
0
        public void Execute(HttpRequest httpRequest, JsonPacket jsonRequest, SessionComponent session)
        {
            // Connect
            NetworkChannel channel = new NetworkChannel(Connection);

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

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

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

            channel.Send(httpResponse);

            // Data
            Entity entity = session.Owner;

            entity.Shutdown();
#if DEBUG
            Log.Add(httpRequest, httpResponse, jsonRequest, jsonResponse);
#endif
        }
Example #2
0
        public HttpCode Execute()
        {
            Clear();

            // Connect
            NetworkChannel channel = null;

            try
            {
                channel = new NetworkChannel(Connection);

                // Request
                JsonQuitRequestMessage jsonRequestMessage = new JsonQuitRequestMessage();
                JsonPacket             jsonRequest        = new JsonPacket(jsonRequestMessage);

                HttpRequest httpRequest = new HttpRequest(Session.Id)
                {
                    Data = Session.Encrypt(jsonRequest)
                };
                channel.Send(httpRequest);

                // Response
                HttpResponse httpResponse;
                channel.Receive(out httpResponse);
                Code = httpResponse.Code;

                if (httpResponse.Ok)
                {
                    JsonPacket jsonResponse = JsonPacket.Parse(Session.Decrypt(httpResponse.Data));
#if DEBUG
                    Log.Add(httpRequest, httpResponse, jsonRequest, jsonResponse);
#endif
                }
            }
            finally
            {
                if (channel != null)
                {
                    channel.Shutdown();
                }
            }

            return(Code);
        }