fix web socket message name for library change

This commit is contained in:
Luke Pulverenti 2013-10-06 14:48:04 -04:00
parent 6e58ae31bd
commit bd5bf32aba
5 changed files with 35 additions and 9 deletions

View file

@ -202,5 +202,13 @@ namespace MediaBrowser.Common.Implementations.Logging
}
}
}
/// <summary>
/// Flushes this instance.
/// </summary>
public void Flush()
{
LogManager.Flush();
}
}
}

View file

@ -35,5 +35,10 @@ namespace MediaBrowser.Model.Logging
/// Occurs when [logger loaded].
/// </summary>
event EventHandler LoggerLoaded;
/// <summary>
/// Flushes this instance.
/// </summary>
void Flush();
}
}

View file

@ -123,7 +123,7 @@ namespace MediaBrowser.Server.Implementations.Session
return socket.SendAsync(new WebSocketMessage<LibraryUpdateInfo>
{
MessageType = "Playstate",
MessageType = "LibraryChanged",
Data = info
}, cancellationToken);

View file

@ -4,7 +4,6 @@ using MediaBrowser.Common.Net;
using MediaBrowser.Model.Logging;
using System;
using System.Net;
using System.Net.Sockets;
namespace MediaBrowser.Server.Implementations.WebSocket
{
@ -29,6 +28,8 @@ namespace MediaBrowser.Server.Implementations.WebSocket
/// </summary>
private readonly ILogger _logger;
private bool _hasStopped;
/// <summary>
/// Initializes a new instance of the <see cref="AlchemyServer" /> class.
/// </summary>
@ -57,6 +58,8 @@ namespace MediaBrowser.Server.Implementations.WebSocket
/// <param name="portNumber">The port number.</param>
public void Start(int portNumber)
{
_logger.Info("Starting Alchemy web socket server on port {0}", portNumber);
try
{
WebSocketServer = new WebSocketServer(portNumber, IPAddress.Any)
@ -87,6 +90,11 @@ namespace MediaBrowser.Server.Implementations.WebSocket
/// <param name="context">The context.</param>
private void OnAlchemyWebSocketClientConnected(UserContext context)
{
if (_hasStopped)
{
return;
}
if (WebSocketConnected != null)
{
var socket = new AlchemyWebSocket(context, _logger);
@ -127,6 +135,8 @@ namespace MediaBrowser.Server.Implementations.WebSocket
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool dispose)
{
_hasStopped = true;
lock (_syncLock)
{
if (WebSocketServer != null)

View file

@ -1,5 +1,4 @@
using System.Runtime.InteropServices;
using MediaBrowser.Common.Constants;
using MediaBrowser.Common.Constants;
using MediaBrowser.Common.Implementations.Logging;
using MediaBrowser.Common.Implementations.Updates;
using MediaBrowser.Controller.IO;
@ -13,6 +12,7 @@ using System.Configuration.Install;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.ServiceProcess;
using System.Windows;
@ -251,9 +251,7 @@ namespace MediaBrowser.ServerApplication
if (_isRestarting)
{
using (var process = Process.Start("cmd", "/c net start " + BackgroundService.Name))
{
}
Process.Start("cmd", "/c net start " + BackgroundService.Name);
_logger.Info("New service process started");
}
@ -383,6 +381,8 @@ namespace MediaBrowser.ServerApplication
_logger.ErrorException("UnhandledException", exception);
_appHost.LogManager.Flush();
if (!_isRunningAsService)
{
_app.OnUnhandledException(exception);
@ -390,7 +390,7 @@ namespace MediaBrowser.ServerApplication
if (!Debugger.IsAttached)
{
Environment.Exit(System.Runtime.InteropServices.Marshal.GetHRForException(exception));
Environment.Exit(Marshal.GetHRForException(exception));
}
}
@ -411,13 +411,16 @@ namespace MediaBrowser.ServerApplication
// Update is there - execute update
try
{
new ApplicationUpdater().UpdateApplication(MBApplication.MBServer, appPaths, updateArchive);
var serviceName = _isRunningAsService ? BackgroundService.Name : string.Empty;
new ApplicationUpdater().UpdateApplication(MBApplication.MBServer, appPaths, updateArchive, logger, serviceName);
// And just let the app exit so it can update
return true;
}
catch (Exception e)
{
logger.ErrorException("Error starting updater.", e);
MessageBox.Show(string.Format("Error attempting to update application.\n\n{0}\n\n{1}", e.GetType().Name, e.Message));
}
}