Ejemplo n.º 1
0
        public void TestingMcastSendingAndReceive()
        {
            var Listener = new UdpSocket("192.168.90.50", 9000);

            //Listener.Base.MulticastLoopback = false;
            Listener.Base.JoinMulticastGroup(IPAddress.Parse("225.12.101.1"), IPAddress.Parse("192.168.90.50"));
            Listener.Base.JoinMulticastGroup(IPAddress.Parse("225.212.101.1"), IPAddress.Parse("192.168.90.50"));
            Listener.NewDataEvent += (s, d) =>
            {
                var from = d.Client.Address;
            };
            Listener.BeginReceive();

            var Sender = new UdpSocket(9001);

            Sender.Base.JoinMulticastGroup(IPAddress.Parse("225.12.101.1"), IPAddress.Parse("192.168.90.50"));
            IPEndPoint to1 = new IPEndPoint(IPAddress.Parse("225.12.101.1"), 9000);
            IPEndPoint to2 = new IPEndPoint(IPAddress.Parse("225.212.101.1"), 9000);

            Task.Delay(1000).Wait();
            Sender.Send(to1, new byte[] { 1, 2, 3 });
            Task.Delay(1000).Wait();
            Sender.Send(to2, new byte[] { 1, 2, 3 });

            Task.Delay(1000).Wait();
        }
Ejemplo n.º 2
0
 public void KcpSend(byte[] buff)
 {
     if (kcpClient != null)
     {
         if (kcpClient.Connected)
         {
             kcpClient.Send(buff);
         }
     }
 }
Ejemplo n.º 3
0
        private void SendConnectionRequest(TrackerGetUdpEntry entry)
        {
            SocketBuffer outgoing = new SocketBuffer(16);

            Array.Copy(TrackerGetUdpProtocol.Id, 0, outgoing.Data, 0, 8);
            Array.Copy(TrackerGetUdpProtocol.Connect, 0, outgoing.Data, 8, 4);
            Array.Copy(entry.Transaction, 0, outgoing.Data, 12, 4);

            entry.Status = TrackerGetUdpStatus.Connecting;
            socket.Send(entry.Endpoint, outgoing, OnSent(entry));
        }
Ejemplo n.º 4
0
 public void SendHeartBeat(UdpSocket udpSocket)
 {
     if (heartbeatStopWatch.Elapsed.TotalSeconds > HEARTBEAT_INTERVAL_SEC)
     {
         udpSocket.Send(PacketUtils.createHeartbeatReceiverPacketBytes(ReceiverId).bytes, SenderEndPoint);
         heartbeatStopWatch = Stopwatch.StartNew();
     }
 }
Ejemplo n.º 5
0
    void OnCheckSequence(UInt32 seq)
    {
        switch (seq)
        {
        case NetHelper.SEQUENCE_KICK:
            Close("ServerClosed");
            break;

        case NetHelper.SEQUENCE_KEEPALIVE:
            mSocket.Send(ACK_DATA);
            break;

        case NetHelper.SEQUENCE_KEEPALIVE_ACK:
            mKeepAliveCount = 10;
            mLastRecvTime   = UdpSocket.iclock();
            break;
        }
    }
Ejemplo n.º 6
0
 private void ListenRedirectSocket(RemoteClient client)
 {
     logger.Info(
         $"Start new listener for redirect endpoint for client {client.EndPoint.ToString()}"
         );
     client.RedirectSocket.Listen(
         (ClientMessage cm) => socket.Send(cm.Message, client.EndPoint)
         );
 }
Ejemplo n.º 7
0
    public string GetCallbackResult()
    {
        string str = "";
        string s   = String.Format("Received ask for {0}", _Command);

        logDebugView.Debug(s);
        try
        {
            if (_Command == "State")
            {
                string[] stateStr = new string[] { "No Funcional", "Activando Nodo", "Activo", "No Activo" };

                Application.Lock();
                NodeInfo node1 = (NodeInfo)Application["ClusterWeb_Node1"];
                NodeInfo node2 = (NodeInfo)Application["ClusterWeb_Node2"];
                Application.UnLock();

                if (node1 != null && node2 != null)
                {
                    bool dataReplicationState = (bool)Application["Data_Replication_State"] && (node1.ReplicationServiceState == "2" && node2.ReplicationServiceState == "2");
                    str = string.Format("Name={0}&State={1}&StateBegin={2}&Adapter1={3}&Adapter2={4}&VirtualIp1={5}&VirtualIp2={6}&ReplicationState={7}&DataReplicationState={8}",
                                        node1.Name, stateStr[(int)node1.State], node1.StateBegin, node1.AdapterIp1, node1.AdapterIp2, node1.VirtualIp1, node1.VirtualIp2, node1.ReplicationServiceState, dataReplicationState);
                    str += "@";
                    str += string.Format("Name={0}&State={1}&StateBegin={2}&Adapter1={3}&Adapter2={4}&VirtualIp1={5}&VirtualIp2={6}&ReplicationState={7}&DataReplicationState={8}",
                                         node2.Name, stateStr[(int)node2.State], node2.StateBegin, node2.AdapterIp1, node2.AdapterIp2, node2.VirtualIp1, node2.VirtualIp2, node2.ReplicationServiceState, dataReplicationState);
                    string s1 = String.Format("Sending state: {0}", str);
                    logDebugView.Debug(s1);
                }
            }
            else if (_Command == "ActivateNode1")
            {
                Application.Lock();
                UdpSocket  comm = (UdpSocket)Application["ClusterWeb_Comm"];
                IPEndPoint ep   = (IPEndPoint)Application["ClusterWeb_EP1"];
                byte[]     msg  = (byte[])Application["ClusterWeb_ActivateMsg"];
                Application.UnLock();

                comm.Send(ep, msg);
            }
            else if (_Command == "ActivateNode2")
            {
                Application.Lock();
                UdpSocket  comm = (UdpSocket)Application["ClusterWeb_Comm"];
                IPEndPoint ep   = (IPEndPoint)Application["ClusterWeb_EP2"];
                byte[]     msg  = (byte[])Application["ClusterWeb_ActivateMsg"];
                Application.UnLock();

                comm.Send(ep, msg);
            }
        }
        catch (Exception ex)
        {
            logDebugView.Error("(Cluster-Default.aspx)GetCallbackResult", ex);
        }

        return(str);
    }
Ejemplo n.º 8
0
        public static void SrvInitOver(Result result = Result.Success, string errStr = "")
        {
            SrvInitOver srvInitOver = new SrvInitOver();

            SrvRes res = CreateSrvRes(SrvMsgType.SrvInitOver, result, errStr);

            res.SrvInitOver = srvInitOver;

            UdpSocket.Send(Serialize(res));
        }
Ejemplo n.º 9
0
        public static void BGameStart(Result result = Result.Success, string errStr = "")
        {
            BGameStart bGameStart = new BGameStart();

            SrvRes res = CreateSrvRes(SrvMsgType.BGameStart, result, errStr);

            res.BGameStart = bGameStart;

            UdpSocket.Send(Serialize(res));
        }
Ejemplo n.º 10
0
        public static void CliInitOver(int userId = 1, ModuleId moduleId = ModuleId.Game)
        {
            CliInitOver cliInitOver = new CliInitOver();

            CliReq req = CreateCliReq(ClientMsgType.CliInitOver, userId, moduleId);

            req.CliInitOver = cliInitOver;

            UdpSocket.Send(Serialize(req));
        }
        private void EchoServer_ReceivedPacket(object sender, ReceivedUdpPacketEventArgs e)
        {
            Console.WriteLine("UdpDemoServer::EchoServer_ReceivedPacket: received: " + e.Size + "bytes from " + e.RemoteIpEndPoint);
            UdpSocket echoServer = sender as UdpSocket;

            if (echoServer != null)
            {
                echoServer.Send(new byte[20], e.RemoteIpEndPoint);
            }
            _received = true;
        }
Ejemplo n.º 12
0
        private static void DoUdp(string[] args)
        {
            if (args.Length == 0)
            {
                return;
            }
            else if (args[0].ToLower() == "open")
            {
                if (isUdpOpen)
                {
                    Console.WriteLine("Udp already opened");
                }
                else
                {
                    isUdpOpen = true;
                }
            }
            else if (args[0].ToLower() == "close")
            {
                if (isUdpOpen)
                {
                    //stop listener threads
                }
                else
                {
                    isUdpOpen = false;
                }
            }
            else if (args[0].ToLower() == "bind")
            {
                //because ipv6 string parsing algorithm is complicated, for now and just in console application using .Net class for it
                System.Net.IPAddress ip = System.Net.IPAddress.Parse(args[1]);

                IPv6Address ipv6Address = new IPv6Address(ip.GetAddressBytes());
                ushort      port        = Convert.ToUInt16(args[2]);

                threadUdpListening = new Thread(() => UDPListenerThread(ipv6Address, port));
                threadUdpListening.Start();
            }
            else if (args[0].ToLower() == "send" && args.Length == 4)
            {
                System.Net.IPAddress ip          = System.Net.IPAddress.Parse(args[1]);
                IPv6Address          ipv6Address = new IPv6Address(ip.GetAddressBytes());

                ushort port = Convert.ToUInt16(args[2]);

                byte[] data = Encoding.UTF8.GetBytes(args[3]);

                UdpSocket udpClient = new UdpSocket();
                udpClient.Connect(ipv6Address, port);
                udpClient.Send(data, data.Length);
                udpClient.Close();
            }
        }
Ejemplo n.º 13
0
        public static void SrvEnterRoom(int playerId = 0, Result result = Result.Success, string errStr = "")
        {
            SrvEnterRoom srvEnterRoom = new SrvEnterRoom();

            srvEnterRoom.PlayerId = playerId;

            SrvRes res = CreateSrvRes(SrvMsgType.SrvEnterRoom, result, errStr);

            res.SrvEnterRoom = srvEnterRoom;

            UdpSocket.Send(Serialize(res));
        }
Ejemplo n.º 14
0
    static void Main(string[] args)
    {
        UdpSocket s = new UdpSocket();

        s.Server("127.0.0.1", 27000);

        UdpSocket c = new UdpSocket();

        c.Client("127.0.0.1", 27000);
        c.Send("TEST!");

        Console.ReadKey();
    }
Ejemplo n.º 15
0
        public static void BGameInit(int seed = 0, List <PlayerInfo> pList = null, Result result = Result.Success, string errStr = "")
        {
            BGameInit bGameInit = new BGameInit();

            bGameInit.Seed = seed;
            bGameInit.PList.AddRange(pList);

            SrvRes res = CreateSrvRes(SrvMsgType.BGameInit, result, errStr);

            res.BGameInit = bGameInit;

            UdpSocket.Send(Serialize(res));
        }
Ejemplo n.º 16
0
        void SendState()
        {
            using (MemoryStream ms = new MemoryStream())
            {
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(ms, _State.LocalNode);

                try
                {
                    if (_Comm != null)
                    {
                        _Comm.Send(_EndPoint, ms.ToArray());
                    }
                }
                catch (Exception ex)
                {
                    Logger.Exception <Cluster>(ex);
                    /** 20171019. Si hay una excepcion aqui entiendo que se ha perdido la LAN interna... */
                    ResetInternalLan();
                }
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        ///
        /// </summary>
        void SendState()
        {
            using (MemoryStream ms = new MemoryStream())
            {
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(ms, _State.LocalNode);

                try
                {
                    if (_Comm != null)
                    {
                        _Comm.Send(_EndPoint, ms.ToArray());
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Log(LogLevel.Error, String.Format("Excepcion en {0}: {1}", Resources.DeleteIpError, ex.Message));
                    /** 20171019. Si hay una excepcion aqui entiendo que se ha perdido la LAN interna... */
                    ResetInternalLan();
                }
            }
        }
Ejemplo n.º 18
0
        public static void CliEnterRoom(int roomId = 0, string name = "", int userId = 1, ModuleId moduleId = ModuleId.Game)
        {
            CliEnterRoom cliEnterRoom = new CliEnterRoom();

            cliEnterRoom.RoomId = roomId;
            cliEnterRoom.Name   = name;

            CliReq req = CreateCliReq(ClientMsgType.CliEnterRoom, userId, moduleId);

            req.CliEnterRoom = cliEnterRoom;

            UdpSocket.Send(Serialize(req));
        }
Ejemplo n.º 19
0
        public static void BGameFrame(int fId = 0, List <CliOperate> operList = null, Result result = Result.Success, string errStr = "")
        {
            BGameFrame bGameFrame = new BGameFrame();

            bGameFrame.FId = fId;
            bGameFrame.OperList.AddRange(operList);

            SrvRes res = CreateSrvRes(SrvMsgType.BGameFrame, result, errStr);

            res.BGameFrame = bGameFrame;

            UdpSocket.Send(Serialize(res));
        }
Ejemplo n.º 20
0
        public static void CliOperate(string direction = "", bool isFire = false, int playerId = 0, int userId = 1, ModuleId moduleId = ModuleId.Game)
        {
            CliOperate cliOperate = new CliOperate();

            cliOperate.Direction = direction;
            cliOperate.IsFire    = isFire;
            cliOperate.PlayerId  = playerId;

            CliReq req = CreateCliReq(ClientMsgType.CliOperate, userId, moduleId);

            req.CliOperate = cliOperate;

            UdpSocket.Send(Serialize(req));
        }
Ejemplo n.º 21
0
        public void RoutingMcastTest()
        {
            // Programar el LISTEN de LAN1 en el simulador.
            var Listener1 = new UdpSocket("10.12.90.1", 19205);

            Listener1.Base.JoinMulticastGroup(IPAddress.Parse("225.12.101.1"), IPAddress.Parse("10.12.90.1"));
            Listener1.NewDataEvent += (s, d) =>
            {
                Debug.WriteLine("Trama Recibida en LISTENER 1");
            };
            Listener1.BeginReceive();
            // Programar el LISTEN de LAN2 en el simulador.
            var Listener2 = new UdpSocket("10.20.91.1", 19205);

            Listener2.Base.JoinMulticastGroup(IPAddress.Parse("225.212.101.1"), IPAddress.Parse("10.20.91.1"));
            Listener2.NewDataEvent += (s, d) =>
            {
                Debug.WriteLine("Trama Recibida en LISTENER 2");
            };
            Listener2.BeginReceive();

            // Envio de la trama por el código del SCV.
            var ScvSender = new UdpSocket("10.12.90.1", 15001);

            ScvSender.Base.MulticastLoopback = false;
            ScvSender.Base.JoinMulticastGroup(IPAddress.Parse("225.12.101.1"), IPAddress.Parse("10.12.90.1"));
            ScvSender.Base.JoinMulticastGroup(IPAddress.Parse("225.212.101.1"), IPAddress.Parse("10.12.90.1"));
            IPEndPoint to1 = new IPEndPoint(IPAddress.Parse("225.12.101.1"), 19205);
            IPEndPoint to2 = new IPEndPoint(IPAddress.Parse("225.212.101.1"), 19205);

            Task.Delay(1000).Wait();
            ScvSender.Send(to1, new byte[] { 1, 2, 3 });
            Task.Delay(1000).Wait();
            ScvSender.Send(to2, new byte[] { 1, 2, 3 });

            Task.Delay(1000).Wait();
        }
Ejemplo n.º 22
0
        bool SendStream(UdpStream stream, UdpHandle handle, bool expandToMtu)
        {
            int bytesToSend = UdpMath.BytesRequired(stream.Ptr);

            if (bytesToSend < mtu && expandToMtu)
            {
                bytesToSend = mtu;
            }

            sendTime     = handle.SendTime;
            sendSequence = handle.ObjSequence;
            sendWindow.Enqueue(handle);
            recvSinceLastSend = 0;

            return(socket.Send(endpoint, stream.Data, bytesToSend));
        }
Ejemplo n.º 23
0
    // Nudge a sender with a connect packet five times.
    private IEnumerator TryConnectToKinectSender(IPEndPoint senderEndPoint)
    {
        Interlocked.Increment(ref connectingCount);

        TextToaster.Toast($"Try Connecting to a Sender: {senderEndPoint}");

        int receiverId = random.Next();

        for (int i = 0; i < 5; ++i)
        {
            udpSocket.Send(PacketUtils.createConnectReceiverPacketBytes(receiverId, true, true).bytes, senderEndPoint);
            yield return(new WaitForSeconds(0.3f));
        }

        Interlocked.Decrement(ref connectingCount);
    }
Ejemplo n.º 24
0
        private async Task AudioLoop()
        {
            var socket = new UdpSocket(EndPointInfo.SocketEndPoint);
            var timer  = new DriftTimer(TimeSpan.FromMilliseconds(PacketIntervalMilliseconds));

            uint   timestamp = 0;
            ushort sequence  = 0;

            try
            {
                while (!_globalCancellationToken.IsCancellationRequested)
                {
                    var packet = GetNextPacket(sequence, timestamp);

                    await timer.Wait(_globalCancellationToken);

                    if (packet.Length > 0)
                    {
                        await socket.Send(packet);
                    }

                    sequence++;
                    timestamp += (uint)SamplesPerPacket;
                }
            }
            catch (TaskCanceledException)
            {
                // ignore
            }
            catch (Exception ex)
            {
                Logger.Error(ex, $"Exception in audio loop: {ex}");
            }
            finally
            {
                Logger.Debug("Audio loop stopped.");
                ClearAudio();
                if (TransmittingAudio)
                {
                    TransmittingAudio = false;
                    Task.Run(() =>
                    {
                        OnAudioStop?.Invoke(this, EventArgs.Empty);
                    }).Forget();
                }
            }
        }
Ejemplo n.º 25
0
    public string GetCallbackResult()
    {
        string str = "";

        _Logger.Debug("Received ask for {0}", _Command);

        if (_Command == "State")
        {
            string[] stateStr = new string[] { "No Funcional", "Activando Nodo", "Activo", "No Activo" };

            Application.Lock();
            NodeInfo node1 = (NodeInfo)Application["ClusterWeb_Node1"];
            NodeInfo node2 = (NodeInfo)Application["ClusterWeb_Node2"];
            Application.UnLock();

            str = string.Format("Name={0}&State={1}&StateBegin={2}&Adapter1={3}&Adapter2={4}&VirtualIp1={5}&VirtualIp2={6}",
                                node1.Name, stateStr[(int)node1.State], node1.StateBegin, node1.AdapterIp1, node1.AdapterIp2, node1.VirtualIp1, node1.VirtualIp2);
            str += "@";
            str += string.Format("Name={0}&State={1}&StateBegin={2}&Adapter1={3}&Adapter2={4}&VirtualIp1={5}&VirtualIp2={6}",
                                 node2.Name, stateStr[(int)node2.State], node2.StateBegin, node2.AdapterIp1, node2.AdapterIp2, node2.VirtualIp1, node2.VirtualIp2);

            _Logger.Debug("Sending state: {0}", str);
        }
        else if (_Command == "ActivateNode1")
        {
            Application.Lock();
            UdpSocket  comm = (UdpSocket)Application["ClusterWeb_Comm"];
            IPEndPoint ep   = (IPEndPoint)Application["ClusterWeb_EP1"];
            byte[]     msg  = (byte[])Application["ClusterWeb_ActivateMsg"];
            Application.UnLock();

            comm.Send(ep, msg);
        }
        else if (_Command == "ActivateNode2")
        {
            Application.Lock();
            UdpSocket  comm = (UdpSocket)Application["ClusterWeb_Comm"];
            IPEndPoint ep   = (IPEndPoint)Application["ClusterWeb_EP2"];
            byte[]     msg  = (byte[])Application["ClusterWeb_ActivateMsg"];
            Application.UnLock();

            comm.Send(ep, msg);
        }

        return(str);
    }
Ejemplo n.º 26
0
    void Start()
    {
        IPAddress address = IPAddress.Parse("127.0.0.1");
        int       port    = 7777;

        Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)
        {
            ReceiveBufferSize = 1024 * 1024
        };

        ringBuffer       = new RingBuffer((int)(KH_LATENCY_SECONDS * 2 * KH_BYTES_PER_SECOND / sizeof(float)));
        udpSocket        = new UdpSocket(socket, new IPEndPoint(address, port));
        audioDecoder     = new AudioDecoder(KH_SAMPLE_RATE, KH_CHANNEL_COUNT);
        lastAudioFrameId = -1;

        udpSocket.Send(PacketHelper.createPingReceiverPacketBytes());
    }
Ejemplo n.º 27
0
    private async void TryConnectToKinectSender(IPEndPoint endPoint)
    {
        ++connectingCount;

        TextToaster.Toast($"Try connecting to a Sender at {endPoint}...");

        var random = new System.Random();
        int receiverSessionId;

        while (true)
        {
            receiverSessionId = random.Next();
            if (kinectReceivers.FirstOrDefault(x => x.ReceiverSessionId == receiverSessionId) == null)
            {
                break;
            }
        }

        var kinectReceiver = new KinectReceiver(receiverSessionId, endPoint);

        kinectReceivers.Add(kinectReceiver);

        // Nudge the sender until a confirm packet is received.
        for (int i = 0; i < 5; ++i)
        {
            if (kinectReceiver.State != PrepareState.Unprepared)
            {
                --connectingCount;
                return;
            }

            udpSocket.Send(PacketHelper.createConnectReceiverPacketBytes(receiverSessionId, true, true), endPoint);
            print($"Sent connect packet #{i}");

            await Task.Delay(300);
        }

        // Give up and forget about the connection if a confirm packet has not been received after all the connect packets.
        if (kinectReceiver.State == PrepareState.Unprepared)
        {
            kinectReceivers.Remove(kinectReceiver);
        }

        --connectingCount;
    }
Ejemplo n.º 28
0
        public UdpClientDemo()
        {
            IPAddress serverIp = IPAddress.Parse("127.0.0.1");

            UdpSocket client = new UdpSocket();

            client.ReceivedPacket += Client_ReceivedPacket;

            Console.WriteLine("UdpDemoClient::ctor: Sending Message to " + serverIp);
            client.Send(new byte[10], new IPEndPoint(serverIp, Port));

            // wait for echo server response.
            while (!_received)
            {
                Thread.Sleep(10);
            }

            client.StopReceive();
        }
Ejemplo n.º 29
0
    public bool UpdateFrame(UdpSocket udpSocket, SenderPacketSet senderPacketSet)
    {
        var videoMessageList = new List <Tuple <int, VideoSenderMessageData> >();

        try
        {
            if (heartbeatStopWatch.Elapsed.TotalSeconds > HEARTBEAT_INTERVAL_SEC)
            {
                udpSocket.Send(PacketHelper.createHeartbeatReceiverPacketBytes(receiverSessionId), senderEndPoint);
                heartbeatStopWatch = Stopwatch.StartNew();
            }

            if (senderPacketSet.ReceivedAny)
            {
                videoMessageAssembler.Assemble(udpSocket,
                                               senderPacketSet.VideoPacketDataList,
                                               senderPacketSet.FecPacketDataList,
                                               textureGroupUpdater.lastVideoFrameId,
                                               videoMessageList);
                audioPacketReceiver.Receive(senderPacketSet.AudioPacketDataList, kinectOrigin.Speaker.RingBuffer);
                receivedAnyStopWatch = Stopwatch.StartNew();
            }
            else
            {
                if (receivedAnyStopWatch.Elapsed.TotalSeconds > HEARTBEAT_TIME_OUT_SEC)
                {
                    UnityEngine.Debug.Log($"Timed out after waiting for {HEARTBEAT_TIME_OUT_SEC} seconds without a received packet.");
                    return(false);
                }
            }
        }
        catch (UdpSocketException e)
        {
            UnityEngine.Debug.Log($"UdpSocketRuntimeError: {e}");
            return(false);
        }

        textureGroupUpdater.UpdateFrame(udpSocket, videoMessageList);
        kinectOrigin.UpdateFrame(senderPacketSet.FloorPacketDataList);

        return(true);
    }
Ejemplo n.º 30
0
        public void TestMethod1()
        {
            var app = new SactaProxy(false);

            app.StartOnConsole(null);

            ConfigurationManager cfgMan = new ConfigurationManager();

            cfgMan.Get((cfg) => {
                // Enviar una trama Ini a TWR
                var twr    = cfg.Dependencies.Where(d => d.Id == "TWR").FirstOrDefault();
                var msg    = SactaMsg.MsgToScv(twr, SactaMsg.MsgType.Init, 0, 0).Serialize();
                var to     = new IPEndPoint(IPAddress.Parse(twr.Comm.If1.Ip), twr.Comm.ListenPort);
                var Sender = new UdpSocket(9000);

                Sender.Send(to, msg);
            });

            Task.Delay(TimeSpan.FromSeconds(1000)).Wait();
            app.StopOnConsole();
        }