/// <summary>
 /// Control message reference ids start with underscores.
 /// This methods inspects a message to see if it is a control message from the server, that requires special handling.
 /// </summary>
 /// <param name="webSocketMessage">A Web Socket message.</param>
 /// <returns>True if the message is a Control Message.</returns>
 private bool IsControlMessage(WebSocketMessage webSocketMessage)
 {
     return(webSocketMessage.ReferenceId.StartsWith("_"));
 }
        /// <summary>
        /// Easy deserializing of Web Socket message payload to a concrete class.
        /// </summary>
        /// <typeparam name="T">The resulting type.</typeparam>
        /// <param name="webSocketMessage">The received Web Socket message.</param>
        /// <returns></returns>
        private T DecodeWebSocketMessagePayload <T>(WebSocketMessage webSocketMessage)
        {
            var messagePayload = Encoding.UTF8.GetString(webSocketMessage.Payload);

            return(JsonConvert.DeserializeObject <T>(messagePayload));
        }
 /// <summary>
 /// Handles messages succesfully delivered.
 /// </summary>
 /// <param name="webSocketMessage">Web Socket message to be handled.</param>
 private void SuccessCallBack(WebSocketMessage webSocketMessage)
 {
     PrintMessage(webSocketMessage);
 }