Exemplo n.º 1
0
        public override async Task <AbstractWebSocketConnection> OnConnected(HttpContext context)
        {
            var name = context.Request.Query["Id"];
            AbstractWebSocketConnection connection = null;

            if (!string.IsNullOrEmpty(name))
            {
                connection = Connections.FirstOrDefault(m => ((WebSocketConnection)m).Id == name);
            }

            if (connection == null)
            {
                var webSocket = await context.WebSockets.AcceptWebSocketAsync();

                connection = new WebSocketConnection(this, Publish)
                {
                    Id        = Guid.NewGuid().ToString(),
                    WebSocket = webSocket
                };

                Connections.Add(connection);

                await connection.Init();
            }

            return(connection);
        }
Exemplo n.º 2
0
 public virtual void Init(AbstractWebSocketConnection connection)
 {
 }