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); } } }
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); }
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()); } }
private void OnChatMessage(ChatPacket packet) { var who = packet.From; var msg = packet.Message; Console.WriteLine("{0} - {1}", who, msg); }