Exemplo n.º 1
0
 /// <summary>
 /// Creates byte array data of only message content
 /// </summary>
 public async Task <byte[]> CreateContent(WebSocketMessage value)
 {
     await using MemoryStream ms = new MemoryStream();
     value.Content.WriteTo(ms);
     return(ms.ToArray());
 }
Exemplo n.º 2
0
        /// <summary>
        /// Sends websocket message to client
        /// </summary>
        public async Task <bool> SendAsync(WebSocketMessage message)
        {
            byte[] data = await _writer.Create(message);

            return(Send(data));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sends string message to client
        /// </summary>
        public async Task SendAsync(string message)
        {
            byte[] data = await _writer.Create(WebSocketMessage.FromString(message));

            Send(data);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Sends websocket message to client
 /// </summary>
 public bool Send(WebSocketMessage message)
 {
     byte[] data = _writer.Create(message).Result;
     return(Send(data));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Sends string message to client
 /// </summary>
 public bool Send(string message)
 {
     byte[] data = _writer.Create(WebSocketMessage.FromString(message)).Result;
     return(Send(data));
 }