public bool AddPlayer(Player player) { if (Game.Players.Contains(player.Id)) { _participants.Add(player); player.MessageRecieved += OnMessageRecieved; player.NameChanged += OnNameChanged; return true; } return false; }
public void RemovePlayer(Player player) { _participants.Remove(player); }
private void OnNameChanged(Player player, string newName) { }
private void ProcessMessage(Player player, string input) { var receivedEvent = JsonConvert.DeserializeObject<EventWrapper>(input); using (var db = MvcApplication.Store.OpenSession()) { switch (receivedEvent.EventType) { case EventType.Message: var message = JsonConvert.DeserializeObject<MessageEvent>(receivedEvent.EventBody); if (SceneIsActive(message.SceneId)) { message.GameId = Game.Id; SendMessage(receivedEvent); } break; } db.SaveChanges(); } }
private void OnMessageRecieved(Player player, string wireMessage) { ProcessMessage(player, wireMessage); }