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

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

            JsonClient jsonClient = jsonRequestMessage.Client;

            if (jsonClient == null)
            {
                channel.SendNotFound();
                return;
            }

            Entity entity = ClientMap.Get(jsonClient.Id);

            if (entity == null)
            {
                channel.SendNotFound();
                return;
            }

            // Command
            TunnelComponent      tunnel  = entity.Get <TunnelComponent>();
            BrowseRequestCommand command = new BrowseRequestCommand(entity, tunnel.Connection);
            string jsonData = command.Execute(jsonRequest.Data);

            if (string.IsNullOrEmpty(jsonData))
            {
                channel.SendNotFound();
                return;
            }

            // Response
            JsonBrowseResponseMessage jsonResponseMessage = new JsonBrowseResponseMessage();
            JsonPacket jsonResponse = new JsonPacket(jsonResponseMessage, jsonData);

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

            channel.Send(httpResponse);
#if DEBUG
            Log.Add(httpRequest, httpResponse, jsonRequest, jsonResponse);
#endif
        }
Exemple #2
0
        private List <BrowseComponent> GetFiles(BrowseComponent browse)
        {
            try
            {
                // NOTE: No need to close the connection
                BrowseRequestCommand command = new BrowseRequestCommand(Owner);
                return(command.Execute(browse.ClientId, browse.Id));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(null);
        }