private void OnPlay(Player p, PlayEvent playEvent) { if (!p.IsAceAllowed(Permission.Play)) { p.AddChatMessage($"You are not permitted to play on this screen. missing ace: \"{Permission.Play}\""); return; } if (!playEvent.IsValid) { p.AddChatMessage($"Play \"{playEvent.Url}\" on screen \"{playEvent.Url}\" failed. Reason: Invalid url"); return; } var screen = this.screenCollection.FindOne(s => s.Name == playEvent.Screen.Name); if (screen == null) { p.AddChatMessage($"Play on screen \"{playEvent.Screen.Name}\" failed. screen not found"); return; } Logger.Debug($"playing: {playEvent.Url} on \"{playEvent.Screen.Name}\""); this.Play.Invoke(null, playEvent); this.screenStateManager.OnPlay(screen, playEvent.Url); }
// Called through export private void OnPlay(string screenName, string videoUrl) { var screen = this.screenCollection.FindOne(s => s.Name == screenName); if (screen == null) { Logger.Error($"play on screen \"{screenName}\" failed. Screen not found"); return; } var playEvent = new PlayEvent() { Screen = screen, Url = videoUrl }; if (!playEvent.IsValid) { Logger.Error($"play \"{playEvent.Url}\" on screen \"{playEvent.Url}\" failed. Reason: Invalid url"); return; } this.Play.Invoke(null, playEvent); this.screenStateManager.OnPlay(screen, videoUrl); Logger.Debug($"playing: {playEvent.Url} on \"{playEvent.Screen.Name}\""); }
private void OnEditScreen(string jsonScreen) { var screen = JsonConvert.DeserializeObject <Screen>(jsonScreen); if (screen == null) { Logger.Error("Failed to edit screen. Received empty or wrong argument"); return; } if (!screen.IsValid) { Logger.Error("Failed to edit screen. Received invalid screen argument"); return; } var found = this.screenCollection.Update(screen); if (!found) { Logger.Error($"Editing failed. screen \"{screen.Name}\" not found."); return; } this.EditScreen.Invoke(null, screen); this.GetScreenList.Invoke(null, this.GetScreensList()); }
// Called through export private void OnPause(string screenName) { var screen = this.screenCollection.FindOne(s => s.Name == screenName); if (screen == null) { Logger.Error($"Pausing failed. Screen \"{screenName}\" not found."); return; } this.Pause.Invoke(null, screenName); this.screenStateManager.OnPause(screenName); }
// Export private void OnSeek(string screenName, float time) { var screen = this.screenCollection.FindOne(s => s.Name == screenName); if (screen == null) { Logger.Error($"seeking failed. Cant find {screenName}"); return; } this.Seek.Invoke(null, screenName, time); this.screenStateManager.OnSeek(screenName, time); }
private void OnDeleteScreen(string screenName) { var count = this.screenCollection.Delete(s => s.Name == screenName); if (count == 0) { Logger.Error($"failed to delete screen. screen {screenName} not found."); return; } this.DeleteScreen.Invoke(null, screenName); this.GetScreenList.Invoke(null, this.GetScreensList()); }
private void OnCreateScreen(string jsonScreen) { var screen = JsonConvert.DeserializeObject <Screen>(jsonScreen); if (screen == null) { Logger.Error($"failed to create new screen. invalid argument"); return; } var existingScreen = this.screenCollection.FindOne(s => s.Name == screen.Name); if (existingScreen != null) { Logger.Error($"failed to create a new screen. A screen with name \"{screen.Name}\" already exists."); return; } var id = this.screenCollection.Insert(screen); screen.Id = id; this.GetScreenList.Invoke(null, this.GetScreensList()); }