Esempio n. 1
0
        public void OnReceived(int streamIndex, ulong id, ScaleoutMessage message)
        {
            JsonSerializer serializer = new JsonSerializer();

            foreach (Message msg in message.Messages)
            {
                string msgString;
                using (ArraySegmentTextReader astr = new ArraySegmentTextReader(msg.Value, msg.Encoding))
                {
                    msgString = astr.ReadToEnd();
                }

                ClientHubInvocation clientHubInvocation = serializer.Parse <ClientHubInvocation>(msgString);

                if (clientHubInvocation.Args != null && clientHubInvocation.Args.Length == 1)
                {
                    byte[] orginalArr = Convert.FromBase64String(clientHubInvocation.Args[0].ToString());
                    var    idArr      = BitConverter.GetBytes(id);
                    byte[] resultArr  = new byte[orginalArr.Length + idArr.Length];

                    idArr.CopyTo(resultArr, 0);
                    orginalArr.CopyTo(resultArr, idArr.Length);

                    clientHubInvocation.Args[0] = Convert.ToBase64String(resultArr.ToArray());

                    StringBuilder sb = new StringBuilder();
                    using (StringWriter sr = new StringWriter(sb))
                    {
                        serializer.Serialize(sr, clientHubInvocation);
                        sr.Flush();
                    }

                    msg.Value = new ArraySegment <byte>(msg.Encoding.GetBytes(sb.ToString()));
                }
            }
        }
Esempio n. 2
0
 public HubOutgoingInvokerContext(IConnection connection, string signal, ClientHubInvocation invocation)
 {
     Connection = connection;
     Signal     = signal;
     Invocation = invocation;
 }
Esempio n. 3
0
 public HubOutgoingInvokerContext(IConnection connection, IList <string> signals, ClientHubInvocation invocation)
 {
     Connection = connection;
     Signals    = signals;
     Invocation = invocation;
 }
Esempio n. 4
0
 public HubOutgoingInvokerContext(IConnection connection, string signal, ClientHubInvocation invocation)
 {
     Connection = connection;
     Signal = signal;
     Invocation = invocation;
 }