Inheritance: IDisposable
示例#1
0
文件: Program.cs 项目: sq/Libraries
        static IEnumerator <object> HandleNewClients()
        {
            while (true)
            {
                IFuture f = Server.AcceptNewClient();
                using (f)
                    yield return(f);

                TelnetClient client = f.Result as TelnetClient;
                Player       player = new Player(client, World.PlayerStartLocation);
            }
        }
        private IEnumerator <object> ListenTask()
        {
            while (true)
            {
                var f = _Listener.AcceptIncomingConnection();
                yield return(f);

                TcpClient tcpClient = f.Result as TcpClient;
                Console.WriteLine("Accepted connection from {0}.", tcpClient.Client.RemoteEndPoint);
                TelnetClient client = new TelnetClient(this, tcpClient);
                _Clients.Add(client);
                _NewClients.Enqueue(client);
            }
        }
示例#3
0
        public Player (TelnetClient client, Location location)
            : base(location, null) {
            Client = client;
            client.RegisterOnDispose(OnDisconnected);

            RebuildCommandTrie();
            AddExitCommands(location);

            AddEventHandler(EventType.CombatHit, OnEventCombatHit);
            AddEventHandler(EventType.CombatMiss, OnEventCombatMiss);
            AddEventHandler(EventType.CombatStart, OnEventCombatStart);
            AddEventHandler(EventType.Death, OnEventDeath);
            AddEventHandler(EventType.Emote, OnEventEmote);
            AddEventHandler(EventType.Enter, OnEventEnter);
            AddEventHandler(EventType.Leave, OnEventLeave);
            AddEventHandler(EventType.Say, OnEventSay);
            AddEventHandler(EventType.Tell, OnEventTell);
        }
示例#4
0
        public Player(TelnetClient client, Location location)
            : base(location, null)
        {
            Client = client;
            client.RegisterOnDispose(OnDisconnected);

            RebuildCommandTrie();
            AddExitCommands(location);

            AddEventHandler(EventType.CombatHit, OnEventCombatHit);
            AddEventHandler(EventType.CombatMiss, OnEventCombatMiss);
            AddEventHandler(EventType.CombatStart, OnEventCombatStart);
            AddEventHandler(EventType.Death, OnEventDeath);
            AddEventHandler(EventType.Emote, OnEventEmote);
            AddEventHandler(EventType.Enter, OnEventEnter);
            AddEventHandler(EventType.Leave, OnEventLeave);
            AddEventHandler(EventType.Say, OnEventSay);
            AddEventHandler(EventType.Tell, OnEventTell);
        }
示例#5
0
 private IEnumerator<object> ListenTask()
 {
     while (true) {
         var f = _Listener.AcceptIncomingConnection();
         yield return f;
         TcpClient tcpClient = f.Result as TcpClient;
         Console.WriteLine("Accepted connection from {0}.", tcpClient.Client.RemoteEndPoint);
         TelnetClient client = new TelnetClient(this, tcpClient);
         _Clients.Add(client);
         _NewClients.Enqueue(client);
     }
 }