using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Session;
using ServiceStack.ServiceHost;
using System.Collections.Generic;
using System.Linq;
namespace MediaBrowser.Api
{
///
/// Class GetSessions
///
[Route("/Sessions", "GET")]
[Api(("Gets a list of sessions"))]
public class GetSessions : IReturn>
{
///
/// Gets or sets a value indicating whether this instance is recent.
///
/// true if this instance is recent; otherwise, false.
public bool IsRecent { get; set; }
}
///
/// Class SessionsService
///
public class SessionsService : BaseApiService
{
///
/// The _session manager
///
private readonly ISessionManager _sessionManager;
///
/// Initializes a new instance of the class.
///
/// The session manager.
public SessionsService(ISessionManager sessionManager)
{
_sessionManager = sessionManager;
}
///
/// Gets the specified request.
///
/// The request.
/// System.Object.
public object Get(GetSessions request)
{
var result = request.IsRecent ? _sessionManager.RecentConnections : _sessionManager.AllConnections;
return ToOptimizedResult(result.ToList());
}
}
}