Beispiel #1
0
        public override async Task OnConnected(WebSocket socket)
        {
            await base.OnConnected(socket);

            var socketId = WebSocketConnectionManager.GetId(socket);

            await SendMessageToAllAsync($"{socketId} is now connected");
        }
Beispiel #2
0
        public override async Task OnDisconnected(WebSocket socket)
        {
            await WebSocketConnectionManager.RemoveSocket(WebSocketConnectionManager.GetId(socket));

            var dictionary = WebSocketConnectionManager.GetAll();

            if (dictionary.Count == 0)
            {
                timer.Dispose();
            }
        }
Beispiel #3
0
        public override async Task OnConnected(WebSocket socket)
        {
            await base.OnConnected(socket);

            var socketId = WebSocketConnectionManager.GetId(socket);

            var dictionary = WebSocketConnectionManager.GetAll();

            if (dictionary.Count == 1)
            {
                var autoEvent = new AutoResetEvent(false);
                timer = new Timer(SendValueAsync, autoEvent, 0, 1000);
            }
        }
Beispiel #4
0
 public WebSocketHandler(WebSocketConnectionManager webSocketConnectionManager)
 {
     WebSocketConnectionManager = webSocketConnectionManager;
 }
Beispiel #5
0
 public ChatMessageHandler(WebSocketConnectionManager webSocketConnectionManager) : base(webSocketConnectionManager)
 {
 }
Beispiel #6
0
 public StockHandler(WebSocketConnectionManager webSocketConnectionManager) : base(webSocketConnectionManager)
 {
 }