public ChatHandler(IPlayerHandler playerHandler, IPropertyRepository propertyRepository) { this.playerHandler = playerHandler; this.propertyRepository = propertyRepository; this.chatMessages = propertyRepository.Load <List <ChatMessage> >(nameof(chatMessages)) ?? new List <ChatMessage>(); }
private void Receive() { while (_status != 0) { if (_tcpClient.Available > 0 || !String.IsNullOrEmpty(_msg)) { try { byte[] arr = new byte[2048]; //string msg = binFormatter.Deserialize(_tcpClient.GetStream()) as string; if (_tcpClient.Available > 0) { _tcpClient.GetStream().Read(arr, 0, arr.Length); _msg += Encoding.UTF8.GetString(arr); } _msg = _msg.Replace("\0", string.Empty); if (Messages.KeepAlive.IsKeepAlive(_msg)) { _msg = _msg.Substring(1); ResetTimer(); } else { int specialByteIndex; string currentMsg = _msgParser.Parse(ref _msg, out specialByteIndex); if (specialByteIndex == -1 || string.IsNullOrEmpty(currentMsg)) { continue; } ResetTimer(); Console.WriteLine(currentMsg); var type = _xmlRootReader.GetMessageType(currentMsg); //Deserialization of the message var serializer = new XmlSerializer(type); IPlayerHandler message = null; using (var stream = new StringReader(currentMsg)) { message = (IPlayerHandler)serializer.Deserialize(stream); } message.HandleOnPlayer(this); } } catch (Exception) { Console.WriteLine("Lost connection"); } } Thread.Sleep(30); } }
public RemoteAdmin() { if (playerHandler == null) { CrearInfrastructuraRemoting(); playerHandler = (IPlayerHandler)Activator.GetObject( typeof(IPlayerHandler), "tcp://" + ConfigurationManager.AppSettings["serverip"] + ":" + ConfigurationManager.AppSettings["remotingport"] + "/PlayerHandler"); if (entries == null) { entries = new Stack <LogEntry>(); } } }
public Game( ILogger logger, IPlayerHandler playerHandler, IChatHandler chatHandler, IActionQueue actionQueue, IPropertyRepository propertyRepository) { this.logger = logger; this.playerHandler = playerHandler; this.chatHandler = chatHandler; this.actionQueue = actionQueue; this.propertyRepository = propertyRepository; this.messageLookup = propertyRepository.Load <ConcurrentDictionary <Guid, TaskCompletionSource <GameActionReply> > >(nameof(messageLookup)) ?? new ConcurrentDictionary <Guid, TaskCompletionSource <GameActionReply> >(); this.context = propertyRepository.Load <GameContext>(nameof(context)) ?? GameContext.CreateEmpty(); }
/// PlayersController constructor public PlayersController(IPlayerHandler playerHandler) { this.playerHandler = playerHandler; }
public EEBLPreInitEvent(IPlayerHandler playerHandler) { this.playerHandler = playerHandler; }
public override bool OnPreInit(EEBLPreInitEvent e) { playerHandler = e.GetPlayerHandler(); playerHandler.OnPlayerJoin_Subscribe(HiPlayer_OnPlayerJoin); return(base.OnPreInit(e)); }