Esempio n. 1
0
        private void PingState()
        {
            try
            {
                // NOTE: No need to close the connection
                PingRequestCommand command = new PingRequestCommand(Owner);
                HttpCode           code    = command.Execute();

                Status = (code == HttpCode.Ok) ? DemonStatus.Success : DemonStatus.Warning;
                State  = DemonState.Quit;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                State  = DemonState.Restart;
                Status = DemonStatus.Error;
            }
        }
Esempio n. 2
0
        public void Execute(HttpRequest httpRequest, JsonPacket jsonRequest, SessionComponent session)
        {
            // Connect
            NetworkChannel channel = new NetworkChannel(Connection);

            // Request
            JsonInfoRequestMessage jsonRequestMessage = JsonInfoRequestMessage.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
            JsonInfoResponseMessage jsonResponseMessage = new JsonInfoResponseMessage()
            {
                Entities = Server.Entities, Sessions = Server.Sessions, Clients = Server.Clients, Groups = Server.Groups
            };
            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
        }
Esempio n. 3
0
        private void Ping()
        {
            lock (List)
            {
                foreach (Entity entity in List)
                {
                    if (entity.Invalid)
                    {
                        continue;
                    }

                    try
                    {
                        // NOTE: No need to close the connection
                        PingRequestCommand command = new PingRequestCommand(entity);
                        command.Execute();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
        }