Пример #1
0
        /// <summary>
        /// Plugin Thread
        /// </summary>

        public void PluginMain()
        {
            //Get the application port for the server
            if (!isRunning) //Application starting the first time
            {
                clientList = new List <Socket>();
                int appPort = default(int);
                Types.InputBoxValue result = new Types.InputBoxValue {
                    dialogResult = DialogResult.OK, result = ""
                };
                if (Integrate.CheckPermission(Permissions.Display, pluginToken))
                {
                    result = ServerSettings.ShowInputBox("Android Bridge", "Please enter a port for the android listener to run on", pluginToken);
                }
                if (result.dialogResult != DialogResult.OK)
                {
                    Console.WriteLine("Port not set or display permission is denied");
                    return;
                }
                ui = new AndroidUI(this);
                Invoke(() => ui.Show());
                appPort      = int.Parse(result.result);
                serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); //Create the socket server
                serverSocket.Bind(new IPEndPoint(IPAddress.Any, appPort));                                  //Bind the server to any interface and the selected port number
                serverSocket.Listen(50000);                                                                 //begin listen max. 50000 pending connections
                serverSocket.BeginAccept(new AsyncCallback(AcceptCallback), null);                          //begin accepting clients
                isRunning = true;                                                                           //Set the application to running state
            }
            else //Application running in the background
            {
                ui = new AndroidUI(this);
                Invoke(() => ui.Show());
            }
        }
Пример #2
0
        /// <summary>
        /// Plugin exit point
        /// </summary>

        public void OnExit()
        {
            isRunning = false;
            CloseAll();
            ui.UnloadAPI();
            ui.Close();
            ui.Dispose();
            ui = null;
        }
        /// <summary>
        /// Plugin Thread
        /// </summary>

        public void PluginMain()
        {
            //Get the application port for the server
            int appPort = default(int);

            Types.InputBoxValue result = ServerSettings.ShowInputBox("Android Bridge", "Please enter a port for the android listener to run on");
            if (result.dialogResult != DialogResult.OK)
            {
                return;
            }
            ui = new AndroidUI(this);
            Invoke(() => ui.Show());
            appPort      = int.Parse(result.result);
            serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); //Create the socket server
            serverSocket.Bind(new IPEndPoint(IPAddress.Any, appPort));                                  //Bind the server to any interface and the selected port number
            serverSocket.Listen(5);                                                                     //begin listen max. 5 pending connections
            serverSocket.BeginAccept(new AsyncCallback(AcceptCallback), null);                          //begin accepting clients
        }