/// <summary> /// Processes the identity message. /// </summary> /// <param name="message">The message.</param> private async void ProcessIdentityMessage(WebSocketMessageInfo message) { _logger.Debug("Received Identity message: " + message.Data); var vals = message.Data.Split('|'); if (vals.Length < 3) { _logger.Error("Client sent invalid identity message."); return; } var client = vals[0]; var deviceId = vals[1]; var version = vals[2]; var deviceName = vals.Length > 3 ? vals[3] : string.Empty; var session = _sessionManager.Sessions .FirstOrDefault(i => string.Equals(i.DeviceId, deviceId) && string.Equals(i.Client, client) && string.Equals(i.ApplicationVersion, version)); if (session == null && !string.IsNullOrEmpty(deviceName)) { _logger.Debug("Logging session activity"); await _sessionManager.LogSessionActivity(client, version, deviceId, deviceName, message.Connection.RemoteEndPoint, null).ConfigureAwait(false); session = _sessionManager.Sessions .FirstOrDefault(i => string.Equals(i.DeviceId, deviceId) && string.Equals(i.Client, client) && string.Equals(i.ApplicationVersion, version)); } if (session != null) { var controller = session.SessionController as WebSocketController; if (controller == null) { controller = new WebSocketController(session, _logger, _sessionManager); } controller.AddWebSocket(message.Connection); session.SessionController = controller; } else { _logger.Warn("Unable to determine session based on identity message: {0}", message.Data); } }
async void _serverManager_WebSocketConnected(object sender, GenericEventArgs <IWebSocketConnection> e) { var session = await GetSession(e.Argument.QueryString, e.Argument.RemoteEndPoint).ConfigureAwait(false); if (session != null) { var controller = session.SessionController as WebSocketController; if (controller == null) { controller = new WebSocketController(session, _logger, _sessionManager); } controller.AddWebSocket(e.Argument); session.SessionController = controller; } else { _logger.Warn("Unable to determine session based on url: {0}", e.Argument.Url); } }
async void _serverManager_WebSocketConnected(object sender, GenericEventArgs<IWebSocketConnection> e) { var session = await GetSession(e.Argument.QueryString, e.Argument.RemoteEndPoint).ConfigureAwait(false); if (session != null) { var controller = session.SessionController as WebSocketController; if (controller == null) { controller = new WebSocketController(session, _logger, _sessionManager); } controller.AddWebSocket(e.Argument); session.SessionController = controller; } else { _logger.Warn("Unable to determine session based on url: {0}", e.Argument.Url); } }
/// <summary> /// Processes the identity message. /// </summary> /// <param name="message">The message.</param> private async void ProcessIdentityMessage(WebSocketMessageInfo message) { _logger.Debug("Received Identity message: " + message.Data); var vals = message.Data.Split('|'); if (vals.Length < 3) { _logger.Error("Client sent invalid identity message."); return; } var client = vals[0]; var deviceId = vals[1]; var version = vals[2]; var deviceName = vals.Length > 3 ? vals[3] : string.Empty; var session = _sessionManager.GetSession(deviceId, client, version); if (session == null && !string.IsNullOrEmpty(deviceName)) { _logger.Debug("Logging session activity"); session = await _sessionManager.LogSessionActivity(client, version, deviceId, deviceName, message.Connection.RemoteEndPoint, null).ConfigureAwait(false); } if (session != null) { var controller = session.SessionController as WebSocketController; if (controller == null) { controller = new WebSocketController(session, _logger, _sessionManager); } controller.AddWebSocket(message.Connection); session.SessionController = controller; } else { _logger.Warn("Unable to determine session based on identity message: {0}", message.Data); } }
/// <summary> /// Processes the identity message. /// </summary> /// <param name="message">The message.</param> private async void ProcessIdentityMessage(WebSocketMessageInfo message) { _logger.Debug("Received Identity message: " + message.Data); var vals = message.Data.Split('|'); var client = vals[0]; var deviceId = vals[1]; var version = vals[2]; var deviceName = vals.Length > 3 ? vals[3] : string.Empty; var session = _sessionManager.Sessions .FirstOrDefault(i => string.Equals(i.DeviceId, deviceId) && string.Equals(i.Client, client) && string.Equals(i.ApplicationVersion, version)); if (session == null && !string.IsNullOrEmpty(deviceName)) { _logger.Debug("Logging session activity"); await _sessionManager.LogSessionActivity(client, version, deviceId, deviceName, null).ConfigureAwait(false); session = _sessionManager.Sessions .FirstOrDefault(i => string.Equals(i.DeviceId, deviceId) && string.Equals(i.Client, client) && string.Equals(i.ApplicationVersion, version)); } if (session != null) { var controller = new WebSocketController(session, _appHost); controller.Sockets.Add(message.Connection); session.SessionController = controller; } else { _logger.Warn("Unable to determine session based on identity message: {0}", message.Data); } }