/// <summary> /// Send to all client to stop playing a sound /// </summary> /// <param name="name">The SoundSpawn Token that identifies the sound instance to stop.</param> /// <returns>The sent message</returns> public static StopSoundMessage SendToAll(string soundSpawnToken) { StopSoundMessage msg = new StopSoundMessage { SoundSpawnToken = soundSpawnToken }; msg.SendToAll(); return(msg); }
/// <summary> /// Send to all client to stop playing a sound /// </summary> /// <param name="name">The name of the sound.</param> /// <returns>The sent message</returns> public static StopSoundMessage SendToAll(string name) { StopSoundMessage msg = new StopSoundMessage { Name = name }; msg.SendToAll(); return(msg); }
void SoundFileChanged(object sender, PropertyChangedEventArgs e) { var sound = (Sound)sender; if (new[] { nameof(Sound.File), nameof(Sound.ServerName), nameof(Sound.ClientName), nameof(Sound.Volume), nameof(Sound.Loop), nameof(Sound.Sync) }.Contains(e.PropertyName)) { if (sound.Sync) { sound.SyncsOutstanding = server.ConnectedClients; sound.IsSynced = server.ConnectedClients == 0; server.Broadcast(new SyncSoundMessage { Timestamp = DateTimeOffset.Now, Sound = sound }, () => { var ignore = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, sound.DecrementSyncsOutstanding); }); } else { server.Broadcast(new SyncSoundMessage { Timestamp = DateTimeOffset.Now, Sound = new Sound { Id = sound.Id } }); } } else if (e.PropertyName == nameof(Sound.Status)) { Message msg = null; switch (sound.Status) { case Status.Playing: msg = new PlaySoundMessage { Timestamp = DateTimeOffset.Now, SoundId = sound.Id }; break; case Status.Paused: msg = new PauseSoundMessage { Timestamp = DateTimeOffset.Now, SoundId = sound.Id }; break; case Status.Stopped: msg = new StopSoundMessage { Timestamp = DateTimeOffset.Now, SoundId = sound.Id }; break; } server.Broadcast(msg); } }
/// <summary> /// Tell all clients to stop playing a sound /// </summary> /// <param name="soundSpawnToken">The SoundSpawn Token that identifies the sound to be stopped</returns> public static void StopNetworked(string soundSpawnToken) { StopSoundMessage.SendToAll(soundSpawnToken); }
/// <summary> /// Tell all clients to stop playing a sound /// </summary> /// <param name="name">The sound to be stopped</param> public static void StopNetworked(string name) { StopSoundMessage.SendToAll(name); }