예제 #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);
     }
 }
예제 #3
0
        /// <summary>Load AblyPlatform.dll, instantiate AblyPlatform.PlatformImpl type.</summary>
        static IoC()
        {
            var name = new AssemblyName("IO.Ably");
            var type = Assembly.Load(name).GetType("IO.Ably.Platform");

            if (type != null)
            {
                var obj = Activator.CreateInstance(type);
                Platform = obj as IPlatform;
            }
            else
            {
                DefaultLogger.Debug("Platform class does not exist. Defaulting Microsoft Websocket library.");
            }
        }
예제 #4
0
 /// <summary>Load AblyPlatform.dll, instantiate AblyPlatform.PlatformImpl type.</summary>
 static IoC()
 {
     try
     {
         var name = new AssemblyName("IO.Ably");
         var asm  = Assembly.Load(name);
         var type = Assembly.Load(name).GetType("IO.Ably.Platform");
         if (type != null)
         {
             var obj = Activator.CreateInstance(type);
             Platform = obj as IPlatform;
         }
         else
         {
             DefaultLogger.Debug("Platform class does not exist. Defaulting Microsoft Websocket library.");
         }
     }
     catch (FileNotFoundException e)
     {
         DefaultLogger.Debug($"Assembly cannot be loaded. Defaulting Microsoft Websocket library. ({e.Message})");
     }
 }