public void SetPlaybackState(string sessionId, PlaybackCategory category, PlaybackState state) { if (string.IsNullOrEmpty(sessionId)) { Logger.Warn("AirplayServer: SetPlaybackState: Empty sessionId"); return; } lock (eventConnectionSync) { AirplaySession eventConnection; if (eventConnections.TryGetValue(sessionId, out eventConnection)) { eventConnection.SendPlaybackState(category, state); } } }
public void SendPlaybackState(PlaybackCategory category, PlaybackState state) { if (state == lastPlaybackState) { return; } lastPlaybackState = state; PlaybackStateInfo info = new PlaybackStateInfo() { Category = category, State = state }; HttpRequest request = new HttpRequest("POST", "/event", "HTTP/1.1"); request["Content-Type"] = "text/x-apple-plist+xml"; request["X-Apple-Session-ID"] = sessionId; string plistXml = PlistCS.Plist.writeXml(info.GetPlist()); //Logger.Debug("Created plist xml - '{0}'", plistXml); request.SetContent(plistXml); Logger.Debug("AirplaySession: Sending playback state '{0}' - '{1}'", category, state); Send(request, true); }