Exemplo n.º 1
0
        /// <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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }