| 
														
															@@ -3,7 +3,6 @@ using MediaBrowser.Common.Net; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 using MediaBrowser.Model.Logging; 
														 | 
														
														 | 
														
															 using MediaBrowser.Model.Logging; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 using MediaBrowser.Model.Net; 
														 | 
														
														 | 
														
															 using MediaBrowser.Model.Net; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 using System; 
														 | 
														
														 | 
														
															 using System; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-using System.Text; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 using System.Threading; 
														 | 
														
														 | 
														
															 using System.Threading; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 using System.Threading.Tasks; 
														 | 
														
														 | 
														
															 using System.Threading.Tasks; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -42,7 +41,7 @@ namespace MediaBrowser.Server.Implementations.WebSocket 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             UserContext = context; 
														 | 
														
														 | 
														
															             UserContext = context; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															             context.SetOnDisconnect(OnDisconnected); 
														 | 
														
														 | 
														
															             context.SetOnDisconnect(OnDisconnected); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            context.SetOnReceive(OnReceive); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            context.SetOnReceive(OnReceiveContext); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															             _logger.Info("Client connected from {0}", context.ClientAddress); 
														 | 
														
														 | 
														
															             _logger.Info("Client connected from {0}", context.ClientAddress); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -50,7 +49,7 @@ namespace MediaBrowser.Server.Implementations.WebSocket 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         /// <summary> 
														 | 
														
														 | 
														
															         /// <summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         /// The _disconnected 
														 | 
														
														 | 
														
															         /// The _disconnected 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         /// </summary> 
														 | 
														
														 | 
														
															         /// </summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        private bool _disconnected = false; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        private bool _disconnected; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         /// <summary> 
														 | 
														
														 | 
														
															         /// <summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         /// Gets or sets the state. 
														 | 
														
														 | 
														
															         /// Gets or sets the state. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         /// </summary> 
														 | 
														
														 | 
														
															         /// </summary> 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -73,25 +72,13 @@ namespace MediaBrowser.Server.Implementations.WebSocket 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         /// Called when [receive]. 
														 | 
														
														 | 
														
															         /// Called when [receive]. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         /// </summary> 
														 | 
														
														 | 
														
															         /// </summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         /// <param name="context">The context.</param> 
														 | 
														
														 | 
														
															         /// <param name="context">The context.</param> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        private void OnReceive(UserContext context) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        private void OnReceiveContext(UserContext context) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         { 
														 | 
														
														 | 
														
															         { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            if (OnReceiveDelegate != null) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if (OnReceive != null) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             { 
														 | 
														
														 | 
														
															             { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 var json = context.DataFrame.ToString(); 
														 | 
														
														 | 
														
															                 var json = context.DataFrame.ToString(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                if (!string.IsNullOrWhiteSpace(json)) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    try 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                        var bytes = Encoding.UTF8.GetBytes(json); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                        OnReceiveDelegate(bytes); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    catch (Exception ex) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                        _logger.ErrorException("Error processing web socket message", ex); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                OnReceive(json); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															          
														 | 
														
														 | 
														
															          
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -128,6 +115,12 @@ namespace MediaBrowser.Server.Implementations.WebSocket 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         /// Gets or sets the receive action. 
														 | 
														
														 | 
														
															         /// Gets or sets the receive action. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         /// </summary> 
														 | 
														
														 | 
														
															         /// </summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         /// <value>The receive action.</value> 
														 | 
														
														 | 
														
															         /// <value>The receive action.</value> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        public Action<byte[]> OnReceiveDelegate { get; set; } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        public Action<byte[]> OnReceiveBytes { get; set; } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /// <summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /// Gets or sets the on receive. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /// </summary> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        /// <value>The on receive.</value> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        public Action<string> OnReceive { get; set; } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 |