aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Session/WebSocketController.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-05-17 14:37:40 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-05-17 14:37:40 -0400
commit715119b525a026f0f60c9dcaae1d4899cbc6bcda (patch)
treeca08551862654a32fa4240c164e4da51a5508457 /MediaBrowser.Server.Implementations/Session/WebSocketController.cs
parentc8e4889ac72b4b6fa01ffd0ccf293363ca5ce744 (diff)
updated nuget
Diffstat (limited to 'MediaBrowser.Server.Implementations/Session/WebSocketController.cs')
-rw-r--r--MediaBrowser.Server.Implementations/Session/WebSocketController.cs34
1 files changed, 32 insertions, 2 deletions
diff --git a/MediaBrowser.Server.Implementations/Session/WebSocketController.cs b/MediaBrowser.Server.Implementations/Session/WebSocketController.cs
index 040705171..6f4dd0a72 100644
--- a/MediaBrowser.Server.Implementations/Session/WebSocketController.cs
+++ b/MediaBrowser.Server.Implementations/Session/WebSocketController.cs
@@ -17,16 +17,19 @@ namespace MediaBrowser.Server.Implementations.Session
public class WebSocketController : ISessionController
{
public SessionInfo Session { get; private set; }
- public List<IWebSocketConnection> Sockets { get; private set; }
+ public IReadOnlyList<IWebSocketConnection> Sockets { get; private set; }
private readonly IServerApplicationHost _appHost;
private readonly ILogger _logger;
- public WebSocketController(SessionInfo session, IServerApplicationHost appHost, ILogger logger)
+ private readonly ISessionManager _sessionManager;
+
+ public WebSocketController(SessionInfo session, IServerApplicationHost appHost, ILogger logger, ISessionManager sessionManager)
{
Session = session;
_appHost = appHost;
_logger = logger;
+ _sessionManager = sessionManager;
Sockets = new List<IWebSocketConnection>();
}
@@ -38,6 +41,11 @@ namespace MediaBrowser.Server.Implementations.Session
}
}
+ public bool SupportsMediaControl
+ {
+ get { return GetActiveSockets().Any(); }
+ }
+
private IEnumerable<IWebSocketConnection> GetActiveSockets()
{
return Sockets
@@ -45,6 +53,28 @@ namespace MediaBrowser.Server.Implementations.Session
.Where(i => i.State == WebSocketState.Open);
}
+ public void AddWebSocket(IWebSocketConnection connection)
+ {
+ var sockets = Sockets.ToList();
+ sockets.Add(connection);
+
+ Sockets = sockets;
+
+ connection.Closed += connection_Closed;
+ }
+
+ void connection_Closed(object sender, EventArgs e)
+ {
+ var capabilities = new SessionCapabilities
+ {
+ PlayableMediaTypes = Session.PlayableMediaTypes,
+ SupportedCommands = Session.SupportedCommands,
+ SupportsMediaControl = SupportsMediaControl
+ };
+
+ _sessionManager.ReportCapabilities(Session.Id, capabilities);
+ }
+
private IWebSocketConnection GetActiveSocket()
{
var socket = GetActiveSockets()