static NebulaClient() { AssemblyDirectory = GetAssemblyDirectory(); MainWindow = Application.Current.MainWindow as MainWindow; Settings = NebulaSettings.LoadSettings(); //Needs to be first Notifications = new NebulaNotifications(); Network = new NebulaNetClient(); MediaPlayer = new MediaPlayer(); Updater = new NebulaUpdater(); Playlists = new PlaylistsManager(); KeyboardHooker = new KeyboardHooker(); SharedSession = new NebulaSharedSession(); Session = new NebulaSession(); //Needs to be latest MediaProviders.Add(new YoutubeMediaProvider()); KeyboardHooker.KeyDown += OnGlobalKeyDown; if (Settings.General.MediaKeyEnabled) { KeyboardHooker.Hook(); } CancellationTokenSource = new CancellationTokenSource(); Task.Run(() => AppTick(CancellationTokenSource.Token, 500)); #if RELEASE CheckForUpdate(true); #endif }
private void OnReceiveSharedSessions(SharedSessionsPollResponse response, NebulaNetClient net) { NebulaClient.Invoke(() => { ListView.Items.Clear(); foreach (SharedSessionInfo sessionInfo in response.Sessions) { ListView.Items.Add(sessionInfo); } }); }
private void OnReceiveSessionUserMessagePacket(SharedSessionUserMessagePacket packet, NebulaNetClient net) { if (!IsSessionActive) { return; } NebulaClient.BeginInvoke(() => AddMessage(new SharedSessionMessage(FindUserById(packet.User.Id), packet.Message))); }
private void OnReceiveSharedSessionUserLeft(SharedSessionUserLeftPacket response, NebulaNetClient net) { if (!IsSessionActive) { return; } NebulaClient.BeginInvoke(() => { UserInfo listUser = FindUserById(response.User.Id); if (listUser == UserInfo.Empty) { return; } Users.Remove(listUser); AddMessage(new SharedSessionMessage(listUser, NebulaClient.GetLocString("SharedSessionMessageUserLeft"), "#fc0000")); }); }
private void OnReceiveSharedSessionUserJoin(SharedSessionUserJoinedPacket response, NebulaNetClient net) { if (!IsSessionActive) { return; } NebulaClient.BeginInvoke(() => { if (IsUserPresent(response.User)) { return; } Users.Add(response.User); AddMessage(new SharedSessionMessage(FindUserById(response.User.Id), NebulaClient.GetLocString("SharedSessionMessageUserJoined"), "#10b513")); }); }
private void OnReceiveSharedSessionJoinResponse(SharedSessionJoinResponse response, NebulaNetClient net) { NebulaClient.BeginInvoke(async() => { switch (response.ResponseCode) { case 0: SetSession(response.Session, response.Users); break; case 10: await NebulaMessageBox.ShowOk("SharedSessionCantJoin", "Session does not exists"); break; case 11: break; case 12: await NebulaMessageBox.ShowOk("SharedSessionCantJoin", "SharedSessionWrongPassword"); break; } }); }