コード例 #1
0
ファイル: ChatClient.cs プロジェクト: jhlllnd/Asgard
        public void Run()
        {
            Connect();

            while(true)
            {
                System.Threading.Thread.Sleep(10);
                if (!_loggedIn)
                {
                    continue;
                }

                string line = Console.ReadLine();
                if (!string.IsNullOrEmpty(line))
                {
                    ChatPacket packet = new ChatPacket();
                    packet.Message = line;
                    Send(packet);
                }
            }
        }
コード例 #2
0
ファイル: ChatServer.cs プロジェクト: jhlllnd/Asgard
        private void OnChatMessage(ChatPacket packet)
        {
            var conn = packet.Connection;
            string who;

            var playerEntity = _playerSystem.Get(conn);
            if (playerEntity != null)
            {
                who = playerEntity.GetComponent<PlayerObject>().DisplayName;
            }
            else
            {
                who = String.Empty;
            }

            var msg = packet.Message;

            var msgTime = GetTime(packet.ReceiveTime).ToString();
            Console.WriteLine("{0} : {1} - {2}", msgTime, who, msg);

            var connections = _playerSystem.Connections.ToList();
            packet.From = who;
            _bifrost.Send(packet, connections, conn);
        }
コード例 #3
0
ファイル: ChatServer.cs プロジェクト: jhlllnd/Asgard
        private void _bifrost_OnDisconnect(NetNode connection)
        {
            var playerEntity = _playerSystem.Get(connection);
            if (playerEntity != null)
            {
                var playerData = playerEntity.GetComponent<PlayerObject>();

                var chatPacket = new ChatPacket();
                chatPacket.Message = playerData.DisplayName + " has disconnected";
                chatPacket.From = "SYSTEM";

                _playerSystem.Remove(playerEntity);

                _bifrost.Send(chatPacket, _playerSystem.Connections.ToList());

            }
        }
コード例 #4
0
ファイル: ChatClient.cs プロジェクト: jhlllnd/Asgard
        private void OnChatMessage(ChatPacket packet)
        {
            var who = packet.From;
            var msg = packet.Message;

            Console.WriteLine("{0} - {1}", who, msg);
        }