Beispiel #1
0
 public void Open(Uri uri, string interfaceName)
 {
     this.socket = IO.Socket(uri);
     socket.On(Socket.EVENT_CONNECT, () =>
     {
         var message        = encoder.CreateMessage();
         message.IsResponse = false;
         message.Action     = "register";
         message.MessageId  = Guid.NewGuid().ToString();
         message.Data       = new
         {
             id       = this.id,
             time     = DateTime.UtcNow,
             contract = interfaceName
         };
         socket.Emit("register", encoder.EncodeMessage(message));
     })
     .On("svcAction", (data) =>
     {
         var token   = JToken.FromObject(data);
         var message = encoder.DecodeMessage(token);
         if (handler != null)
         {
             handler(message);
         }
     })
     .On(Socket.EVENT_ERROR, (data) =>
     {
         System.Diagnostics.Trace.WriteLine(data.ToString());
     });
 }
        public static MessageEnvelope Marshal <T>(this MessageEnvelope <T> envelope, IMessageEncoder encoder)
        {
            var message = envelope.ConvertToNonGeneric();

            message.Body = encoder.EncodeMessage(envelope.Message);
            return(message);
        }
 public void Send(int msgID, byte[] dataBytes)
 {
     if (!IsConnected)
     {
         return;
     }
     byte[] datas = messageEncoder.EncodeMessage(msgID, dataBytes);
     network.SendAsync(datas);
 }
Beispiel #4
0
 private static Action <Stream> GetEncodedContents(TModel model, IMessageEncoder encoder)
 {
     return(outputStream =>
     {
         try
         {
             using (var stream = new UnclosableStreamWrapper(outputStream))
             {
                 var buffer = encoder.EncodeMessage(model);
                 stream.Write(buffer, 0, buffer.Length);
             }
         }
         catch (Exception ex)
         {
             _log.Error(ex.Message, ex);
         }
     });
 }
Beispiel #5
0
        public void PublishData <T>(T t)
        {
            var data = mEncoder.EncodeMessage(t);

            PublishData(data);
        }
Beispiel #6
0
 public void Put(string requestUri, object content)
 {
     PutEncoded(requestUri, _encoder.EncodeMessage(content));
 }
Beispiel #7
0
 public byte[] EncodeMessage <T>(T messageData)
 {
     return(_encoder.EncodeMessage(messageData));
 }
Beispiel #8
0
 public HttpStatusCode Put(string url, object content)
 {
     return(PutEncoded(url, _encoder.EncodeMessage(content)));
 }
 public static byte[] ToBytes(this MessageEnvelope envelope, IMessageEncoder encoder)
 {
     return(encoder.EncodeMessage(envelope));
 }
Beispiel #10
0
 public byte[] EncodeFrameData <T>(T frameData)
 {
     return(_encoder.EncodeMessage(frameData));
 }