コード例 #1
0
        /// <summary>
        /// Thread which listens for remotely connected clients.
        /// </summary>
        private void ListenForClients()
        {
            started = true;
            TcpListener tcpListener = new TcpListener(IPAddress.Any, _port);            //TODO: Add support for specified IP addresses.

            tcpListener.Start();
            while (true)
            {
                //Blocks the thread until a client had connected.
                TcpClient RemoteTcpClient = tcpListener.AcceptTcpClient();
                //new TcpClient() { Client = tcpListener.Server.Accept(); };
                SessionStartedEventArgs e = new SessionStartedEventArgs((IPEndPoint)RemoteTcpClient.Client.RemoteEndPoint, RemoteTcpClient);
                MinecraftBot.Events.RaiseSessionStarted(e);
                //Create a thread to handle communication with the connected remote client.
                RemoteClient client       = new RemoteClient();
                Thread       clientThread = new Thread(delegate() { client.Start(RemoteTcpClient, this); });
                clientThread.Start();
                Clients.Add(client);
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: diassoft/Commanding
 private static void Cmd_SessionStarted(object sender, SessionStartedEventArgs e)
 {
     Console.WriteLine("Session Started: " + e.SessionID);
 }
コード例 #3
0
 static void RemoteSessionStarted(object sender, SessionStartedEventArgs e)
 {
     Console.ForegroundColor = ConsoleColor.Yellow;
     Console.WriteLine("Session started with {0}", e.RemoteEndPoint);
     Console.ResetColor();
 }