updated nuget

This commit is contained in:
Luke Pulverenti
2014-05-17 14:37:40 -04:00
parent c8e4889ac7
commit 715119b525
21 changed files with 134 additions and 23 deletions

View File

@@ -45,6 +45,11 @@ namespace MediaBrowser.Server.Implementations.Session
}
}
public bool SupportsMediaControl
{
get { return true; }
}
private Task SendMessage(object obj, CancellationToken cancellationToken)
{
var json = _json.SerializeToString(obj);

View File

@@ -1164,7 +1164,7 @@ namespace MediaBrowser.Server.Implementations.Session
SupportedCommands = session.SupportedCommands,
UserName = session.UserName,
NowPlayingItem = session.NowPlayingItem,
SupportsRemoteControl = session.SupportsMediaControl,
PlayState = session.PlayState
};

View File

@@ -138,10 +138,10 @@ namespace MediaBrowser.Server.Implementations.Session
if (controller == null)
{
controller = new WebSocketController(session, _appHost, _logger);
controller = new WebSocketController(session, _appHost, _logger, _sessionManager);
}
controller.Sockets.Add(message.Connection);
controller.AddWebSocket(message.Connection);
session.SessionController = controller;
}

View File

@@ -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()