Пример #1
0
 public void Test()
 {
     udp            = new AsyncUDP(1313, true, true, __INIT);
     udp.OnLog     += new AsyncUDP.LogHandler(LogHandler);
     udp.OnCommand += new AsyncUDP.CommandHandler(KeyHandler);
     udp.Start();
 }
Пример #2
0
 private void btnStart_Click(object sender, EventArgs e)
 {
     btnStart.Enabled = false;
     _Server.Start(new IPEndPoint(IPAddress.Parse(cboIP.Text), Convert.ToInt32(txtPort.Text)));
     if (_Server.IsStarted)
     {
         btnStop.Enabled = true;
     }
     else
     {
         btnStart.Enabled = true;
     }
 }
Пример #3
0
        public void KeyHandler(object a, CommandArgs e)
        {
            switch (e.Message)
            {
            case "info":
                Console.SetCursorPosition(0, Console.CursorTop - 1);
                writer.Custom("UDP Server Information:", Color.DarkMagenta);
                StringFormatter("Port: ", udp.Port.ToString());
                StringFormatter("Status: ", udp.Status);
                StringFormatter("Is Handling Commands: ", udp.IsHandlingKeys.ToString());
                StringFormatter("Is Outputting to Log: ", udp.IsOutputing.ToString());
                logger.LogCustom(e.Message);
                break;

            case "start":
                Console.SetCursorPosition(0, Console.CursorTop - 1);
                udp.Start();
                break;

            case "stop":
                Console.SetCursorPosition(0, Console.CursorTop - 1);
                udp.Stop();
                break;

            case "clear":
                Console.Clear();
                writer.Custom("Console cleared.", Color.Blue);
                break;

            case "":
                Console.SetCursorPosition(0, Console.CursorTop - 1);
                break;

            default:
                Console.SetCursorPosition(0, Console.CursorTop - 1);
                writer.Custom("Unknown command: " + e.Message, Color.DarkMagenta);
                logger.LogCustom(e.Message);
                break;
            }
        }
Пример #4
0
 void Start()
 {
     udp = new AsyncUDP (LISTENING_PORT, BROADCAST_PORT);
     udp.Start ();
 }