Ejemplo n.º 1
0
        static void ListenerMenu(SockMgr sockMgr)
        {
            Console.WriteLine("[Interface Menu]");
            Console.WriteLine("1. Close");

            Console.Write("> ");
            string sel = Console.ReadLine();

            switch (sel)
            {
            case "1":
                sockMgr.Shutdown();
                break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
        static void InterfaceMenu(SockMgr sockMgr)
        {
            bool isExit = false;

            while (!isExit && !sockMgr.IsShutdown)
            {
                Console.WriteLine(string.Format("[Interface Menu] {0} -> {1}",
                                                sockMgr.GetSockBase().GetSocket().LocalEndPoint.ToString(),
                                                sockMgr.GetSockBase().GetSocket().RemoteEndPoint.ToString()));
                Console.WriteLine("1. Send Text");
                Console.WriteLine("2. Close");
                Console.WriteLine("3. Is Host?");
                Console.WriteLine("4. Exit");
                Console.WriteLine("5. Config AES");
                Console.WriteLine("6. Send Small File");
                foreach (var proto in sockMgr.GetProtocolStack().GetState().MiddleProtocols)
                {
                    if (proto.GetType() == typeof(Protocol.AESProtocol) && ((Protocol.AESProtocol)proto).GetState().Enabled == false)
                    {
                        Console.WriteLine("[Warning] There exists an AES layer that is not enabled");
                    }
                }

                Console.Write("> ");
                string sel = Console.ReadLine();
                if (sockMgr.IsShutdown)
                {
                    break;
                }
                try
                {
                    switch (sel)
                    {
                    case "1":
                        SendTextConsole(sockMgr);
                        break;

                    case "2":
                        sockMgr.Shutdown();
                        break;

                    case "3":
                        Console.WriteLine(sockMgr.GetSockBase().IsHost.ToString());
                        break;

                    case "4":
                        isExit = true;
                        break;

                    case "5":
                        InterfaceAesConsole(sockMgr);
                        break;

                    case "6":
                        SendSmallFileConsole(sockMgr);
                        break;

                    default:
                        break;
                    }
                }
                catch (NullReferenceException) { }  // in case the remote has shutdown
            }
        }