diff options
Diffstat (limited to 'Emby.Server.Implementations')
3 files changed, 0 insertions, 191 deletions
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 3cc6151f1..05398984b 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -2437,53 +2437,6 @@ namespace Emby.Server.Implementations } } } - - private Dictionary<string, string> _values; - public string GetValue(string name) - { - if (_values == null) - { - _values = LoadValues(); - } - - string value; - - if (_values.TryGetValue(name, out value)) - { - return value; - } - - return null; - } - - // TODO: @bond Remove? - private Dictionary<string, string> LoadValues() - { - Dictionary<string, string> values = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); - - using (var stream = typeof(ApplicationHost).Assembly.GetManifestResourceStream(typeof(ApplicationHost).Namespace + ".values.txt")) - { - using (var reader = new StreamReader(stream)) - { - while (!reader.EndOfStream) - { - var line = reader.ReadLine(); - if (string.IsNullOrEmpty(line)) - { - continue; - } - - var index = line.IndexOf('='); - if (index != -1) - { - values[line.Substring(0, index)] = line.Substring(index + 1); - } - } - } - } - - return values; - } } internal class CertificateInfo diff --git a/Emby.Server.Implementations/Session/FirebaseSessionController.cs b/Emby.Server.Implementations/Session/FirebaseSessionController.cs deleted file mode 100644 index cfe513305..000000000 --- a/Emby.Server.Implementations/Session/FirebaseSessionController.cs +++ /dev/null @@ -1,131 +0,0 @@ -using MediaBrowser.Controller.Session; -using MediaBrowser.Model.Net; -using MediaBrowser.Common.Net; -using MediaBrowser.Model.Serialization; -using System; -using System.Threading; -using System.Threading.Tasks; -using System.Text; -using MediaBrowser.Common; - -namespace Emby.Server.Implementations.Session -{ - public class FirebaseSessionController : ISessionController - { - private readonly IHttpClient _httpClient; - private readonly IJsonSerializer _json; - private readonly ISessionManager _sessionManager; - - public SessionInfo Session { get; private set; } - - private readonly string _token; - - private IApplicationHost _appHost; - private string _senderId; - private string _applicationId; - - public FirebaseSessionController(IHttpClient httpClient, - IApplicationHost appHost, - IJsonSerializer json, - SessionInfo session, - string token, ISessionManager sessionManager) - { - _httpClient = httpClient; - _json = json; - _appHost = appHost; - Session = session; - _token = token; - _sessionManager = sessionManager; - - _applicationId = _appHost.GetValue("firebase_applicationid"); - _senderId = _appHost.GetValue("firebase_senderid"); - } - - public static bool IsSupported(IApplicationHost appHost) - { - return !string.IsNullOrEmpty(appHost.GetValue("firebase_applicationid")) && !string.IsNullOrEmpty(appHost.GetValue("firebase_senderid")); - } - - public bool IsSessionActive - { - get - { - return (DateTime.UtcNow - Session.LastActivityDate).TotalDays <= 3; - } - } - - public bool SupportsMediaControl - { - get { return true; } - } - - public async Task SendMessage<T>(string name, string messageId, T data, ISessionController[] allControllers, CancellationToken cancellationToken) - { - if (!IsSessionActive) - { - return; - } - - if (string.IsNullOrEmpty(_senderId) || string.IsNullOrEmpty(_applicationId)) - { - return; - } - - foreach (var controller in allControllers) - { - // Don't send if there's an active web socket connection - if ((controller is WebSocketController) && controller.IsSessionActive) - { - return; - } - } - - var msg = new WebSocketMessage<T> - { - Data = data, - MessageType = name, - MessageId = messageId, - ServerId = _appHost.SystemId - }; - - var req = new FirebaseBody<T> - { - to = _token, - data = msg - }; - - var byteArray = Encoding.UTF8.GetBytes(_json.SerializeToString(req)); - - var enableLogging = false; - -#if DEBUG - enableLogging = true; -#endif - - var options = new HttpRequestOptions - { - Url = "https://fcm.googleapis.com/fcm/send", - RequestContentType = "application/json", - RequestContentBytes = byteArray, - CancellationToken = cancellationToken, - LogRequest = enableLogging, - LogResponse = enableLogging, - LogErrors = enableLogging - }; - - options.RequestHeaders["Authorization"] = string.Format("key={0}", _applicationId); - options.RequestHeaders["Sender"] = string.Format("id={0}", _senderId); - - using (var response = await _httpClient.Post(options).ConfigureAwait(false)) - { - - } - } - } - - internal class FirebaseBody<T> - { - public string to { get; set; } - public WebSocketMessage<T> data { get; set; } - } -} diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index 2b2b3c677..9911cd0c6 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -1577,14 +1577,6 @@ namespace Emby.Server.Implementations.Session { session.Capabilities = capabilities; - if (!string.IsNullOrEmpty(capabilities.PushToken)) - { - if (string.Equals(capabilities.PushTokenType, "firebase", StringComparison.OrdinalIgnoreCase) && FirebaseSessionController.IsSupported(_appHost)) - { - EnsureFirebaseController(session, capabilities.PushToken); - } - } - if (saveCapabilities) { EventHelper.FireEventIfNotNull(CapabilitiesChanged, this, new SessionEventArgs @@ -1604,11 +1596,6 @@ namespace Emby.Server.Implementations.Session } } - private void EnsureFirebaseController(SessionInfo session, string token) - { - session.EnsureController<FirebaseSessionController>(s => new FirebaseSessionController(_httpClient, _appHost, _jsonSerializer, s, token, this)); - } - private ClientCapabilities GetSavedCapabilities(string deviceId) { return _deviceManager.GetCapabilities(deviceId); |
