using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller.Authentication; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Security; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Events; using MediaBrowser.Model.Session; namespace MediaBrowser.Controller.Session { /// /// Interface ISessionManager /// public interface ISessionManager { /// /// Occurs when [playback start]. /// event EventHandler PlaybackStart; /// /// Occurs when [playback progress]. /// event EventHandler PlaybackProgress; /// /// Occurs when [playback stopped]. /// event EventHandler PlaybackStopped; /// /// Occurs when [session started]. /// event EventHandler SessionStarted; /// /// Occurs when [session ended]. /// event EventHandler SessionEnded; event EventHandler SessionActivity; /// /// Occurs when [capabilities changed]. /// event EventHandler CapabilitiesChanged; /// /// Occurs when [authentication failed]. /// event EventHandler> AuthenticationFailed; /// /// Occurs when [authentication succeeded]. /// event EventHandler> AuthenticationSucceeded; /// /// Gets the sessions. /// /// The sessions. IEnumerable Sessions { get; } /// /// Logs the user activity. /// /// Type of the client. /// The app version. /// The device id. /// Name of the device. /// The remote end point. /// The user. SessionInfo LogSessionActivity(string appName, string appVersion, string deviceId, string deviceName, string remoteEndPoint, Jellyfin.Data.Entities.User user); void UpdateDeviceName(string sessionId, string reportedDeviceName); /// /// Used to report that playback has started for an item /// /// The info. /// Task. Task OnPlaybackStart(PlaybackStartInfo info); /// /// Used to report playback progress for an item /// /// The info. /// Task. /// Task OnPlaybackProgress(PlaybackProgressInfo info); Task OnPlaybackProgress(PlaybackProgressInfo info, bool isAutomated); /// /// Used to report that playback has ended for an item /// /// The info. /// Task. /// Task OnPlaybackStopped(PlaybackStopInfo info); /// /// Reports the session ended. /// /// The session identifier. /// Task. void ReportSessionEnded(string sessionId); /// /// Sends the general command. /// /// The controlling session identifier. /// The session identifier. /// The command. /// The cancellation token. /// Task. Task SendGeneralCommand(string controllingSessionId, string sessionId, GeneralCommand command, CancellationToken cancellationToken); /// /// Sends the message command. /// /// The controlling session identifier. /// The session id. /// The command. /// The cancellation token. /// Task. Task SendMessageCommand(string controllingSessionId, string sessionId, MessageCommand command, CancellationToken cancellationToken); /// /// Sends the play command. /// /// The controlling session identifier. /// The session id. /// The command. /// The cancellation token. /// Task. Task SendPlayCommand(string controllingSessionId, string sessionId, PlayRequest command, CancellationToken cancellationToken); /// /// Sends the browse command. /// /// The controlling session identifier. /// The session id. /// The command. /// The cancellation token. /// Task. Task SendBrowseCommand(string controllingSessionId, string sessionId, BrowseRequest command, CancellationToken cancellationToken); /// /// Sends the playstate command. /// /// The controlling session identifier. /// The session id. /// The command. /// The cancellation token. /// Task. Task SendPlaystateCommand(string controllingSessionId, string sessionId, PlaystateRequest command, CancellationToken cancellationToken); /// /// Sends the message to admin sessions. /// /// /// The name. /// The data. /// The cancellation token. /// Task. Task SendMessageToAdminSessions(string name, T data, CancellationToken cancellationToken); /// /// Sends the message to user sessions. /// /// /// Task. Task SendMessageToUserSessions(List userIds, string name, T data, CancellationToken cancellationToken); Task SendMessageToUserSessions(List userIds, string name, Func dataFn, CancellationToken cancellationToken); /// /// Sends the message to user device sessions. /// /// /// The device identifier. /// The name. /// The data. /// The cancellation token. /// Task. Task SendMessageToUserDeviceSessions(string deviceId, string name, T data, CancellationToken cancellationToken); /// /// Sends the restart required message. /// /// The cancellation token. /// Task. Task SendRestartRequiredNotification(CancellationToken cancellationToken); /// /// Sends the server shutdown notification. /// /// The cancellation token. /// Task. Task SendServerShutdownNotification(CancellationToken cancellationToken); /// /// Sends the server restart notification. /// /// The cancellation token. /// Task. Task SendServerRestartNotification(CancellationToken cancellationToken); /// /// Adds the additional user. /// /// The session identifier. /// The user identifier. void AddAdditionalUser(string sessionId, Guid userId); /// /// Removes the additional user. /// /// The session identifier. /// The user identifier. void RemoveAdditionalUser(string sessionId, Guid userId); /// /// Reports the now viewing item. /// /// The session identifier. /// The item identifier. void ReportNowViewingItem(string sessionId, string itemId); /// /// Reports the now viewing item. /// /// The session identifier. /// The item. void ReportNowViewingItem(string sessionId, BaseItemDto item); /// /// Authenticates the new session. /// /// The request. /// Task{SessionInfo}. Task AuthenticateNewSession(AuthenticationRequest request); /// /// Creates the new session. /// /// The request. /// Task<AuthenticationResult>. Task CreateNewSession(AuthenticationRequest request); /// /// Reports the capabilities. /// /// The session identifier. /// The capabilities. void ReportCapabilities(string sessionId, ClientCapabilities capabilities); /// /// Reports the transcoding information. /// /// The device identifier. /// The information. void ReportTranscodingInfo(string deviceId, TranscodingInfo info); /// /// Clears the transcoding information. /// /// The device identifier. void ClearTranscodingInfo(string deviceId); /// /// Gets the session. /// /// The device identifier. /// The client. /// The version. /// SessionInfo. SessionInfo GetSession(string deviceId, string client, string version); /// /// Gets the session by authentication token. /// /// The token. /// The device identifier. /// The remote endpoint. /// SessionInfo. SessionInfo GetSessionByAuthenticationToken(string token, string deviceId, string remoteEndpoint); /// /// Gets the session by authentication token. /// /// The information. /// The device identifier. /// The remote endpoint. /// The application version. /// Task<SessionInfo>. SessionInfo GetSessionByAuthenticationToken(AuthenticationInfo info, string deviceId, string remoteEndpoint, string appVersion); /// /// Logouts the specified access token. /// /// The access token. /// Task. void Logout(string accessToken); void Logout(AuthenticationInfo accessToken); /// /// Revokes the user tokens. /// /// Task. void RevokeUserTokens(Guid userId, string currentAccessToken); /// /// Revokes the token. /// /// The identifier. /// Task. void RevokeToken(string id); void CloseIfNeeded(SessionInfo session); } }