mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-24 09:44:47 +03:00
added ability to track web sockets per session
This commit is contained in:
54
MediaBrowser.Api/SessionsService.cs
Normal file
54
MediaBrowser.Api/SessionsService.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using MediaBrowser.Controller.Session;
|
||||
using MediaBrowser.Model.Session;
|
||||
using ServiceStack.ServiceHost;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Api
|
||||
{
|
||||
/// <summary>
|
||||
/// Class GetSessions
|
||||
/// </summary>
|
||||
[Route("/Sessions", "GET")]
|
||||
[Api(("Gets a list of sessions"))]
|
||||
public class GetSessions : IReturn<List<SessionInfo>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance is recent.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is recent; otherwise, <c>false</c>.</value>
|
||||
public bool IsRecent { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class SessionsService
|
||||
/// </summary>
|
||||
public class SessionsService : BaseApiService
|
||||
{
|
||||
/// <summary>
|
||||
/// The _session manager
|
||||
/// </summary>
|
||||
private readonly ISessionManager _sessionManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SessionsService"/> class.
|
||||
/// </summary>
|
||||
/// <param name="sessionManager">The session manager.</param>
|
||||
public SessionsService(ISessionManager sessionManager)
|
||||
{
|
||||
_sessionManager = sessionManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetSessions request)
|
||||
{
|
||||
var result = request.IsRecent ? _sessionManager.RecentConnections : _sessionManager.AllConnections;
|
||||
|
||||
return ToOptimizedResult(result.ToList());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user