private ArraySegment <byte> GetMessageInBytes(PoloniexCommand command) { StringWriter writer = new StringWriter(); JsonTextWriter tokenWriter = new JsonTextWriter(writer) { Formatting = Formatting.None }; mSerializer.Serialize(tokenWriter, command); string formatted = writer.ToString(); byte[] bytes = Encoding.UTF8.GetBytes(formatted); return(new ArraySegment <byte>(bytes)); }
public Task SendAsync(PoloniexCommand command) { ArraySegment <byte> messageToSend = GetMessageInBytes(command); return(mWebSocket.SendAsync(messageToSend, WebSocketMessageType, true, mCancellationToken)); }