Exemple #1
0
        public async Task SendAsync(NotificationDescriptor notifyDescriptor)
        {
            if (_clientWebSocket == null || _clientWebSocket.State != WebSocketState.Open)
            {
                return;
            }

            var bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(notifyDescriptor));
            await _clientWebSocket.SendAsync(new ArraySegment <byte>(bytes), WebSocketMessageType.Text, true, CancellationToken.None);
        }
Exemple #2
0
        public async Task Keepalive()
        {
            if (_clientWebSocket == null || _clientWebSocket.State != WebSocketState.Open)
            {
                return;
            }

            NotificationDescriptor invocationDescriptor = new NotificationDescriptor
            {
                NotifyName = "KeepAlive",
                Arguments  = new object[] { ConnectionId },
                Sender     = ""
            };

            var bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(invocationDescriptor));
            await _clientWebSocket.SendAsync(new ArraySegment <byte>(bytes), WebSocketMessageType.Text, true, CancellationToken.None);
        }
 private void _wsConnection_OnNotification(object sender, NotificationDescriptor descriptor)
 {
     OnNotification?.Invoke(sender, descriptor);
 }