//public abstract List<Role> Roles { get; } public void Send(WampMessage message) { var messageString = message.ToString(); if (AuditService != null) { AuditService.StoreMessage(message); } Send(messageString); }
public async Task Send(WampMessage message) { if (Client.State == WebSocketState.Open) { var json = message.ToString(); var bytes = Encoding.UTF8.GetBytes(json); var segment = new ArraySegment <byte>(bytes); lock (sendLock) Client.SendAsync(segment, WebSocketMessageType.Text, true, CancellationToken.None).Wait(); } else { throw new Exception("Websocket state is not OPEN so can't send. Status is: " + Client.State); } }