コード例 #1
0
 /// <summary>
 /// Decodes a json representation of an array of messages using the default list of encoders.
 /// </summary>
 /// <param name="messagesJson">json representation of an array of messages.</param>
 /// <param name="options">optional channel options. <see cref="ChannelOptions"/>.</param>
 /// <returns>array of decoded messages.</returns>
 /// <exception cref="AblyException">AblyException if there is an issue decoding the message. The most likely error is invalid json string.</exception>
 public static Message[] FromEncodedArray(string messagesJson, ChannelOptions options = null)
 {
     try
     {
         var messages = JsonHelper.Deserialize <List <Message> >(messagesJson).ToArray();
         return(FromEncodedArray(messages, options));
     }
     catch (Exception e)
     {
         DefaultLogger.Error($"Error decoding message: {messagesJson}", e);
         throw new AblyException("Error decoding messages. Error: " + e.Message, ErrorCodes.InternalError);
     }
 }
コード例 #2
0
 public static Message FromEncoded(string messageJson, ChannelOptions options = null)
 {
     try
     {
         var message = JsonHelper.Deserialize <Message>(messageJson);
         return(FromEncoded(message, options));
     }
     catch (Exception e)
     {
         DefaultLogger.Error($"Error decoding message: {messageJson}", e);
         throw new AblyException("Error decoding message. Error: " + e.Message, 50000);
     }
 }