Exemplo n.º 1
0
        static void Main(string[] args)
        {
            IChannel ch = new PipelineChannel();

            thro_each = 10000;
            var in_interface = "tcp://*:8765";       /// recibo las respuestas
            //var out_address = "tcp://127.0.0.1:5678"; /// envio los pedidos
            var out_address = "tcp://10.8.0.1:5678"; /// envio los pedidos

            ch.Setup(out_address, in_interface, 12);
            ch.MessageReceived += ch_MessageReceived;
            ch.Start();

            var send_seq = 0;

            Console.Out.WriteLine("Presione una CTRL+BREAK para salir!");

            while (true)
            {
                var xmlmsg = "";

                /*if (ventana > 100)
                 * {
                 *  Thread.Sleep(50);
                 * }
                 * if (ventana > 2000)
                 * {
                 *  while(ventana > 1500) Thread.Sleep(500);
                 *  continue;
                 * }*/
                if ((enviados++) % 1000 == 0)
                {
                    xmlmsg = "<token t='" + DateTime.Now.Ticks + "'/>";
                }
                else
                {
                    xmlmsg = "<message label='jelo guor' q='" + (send_seq++) + "'/>";
                    ventana++;
                }
                var msg = Encoding.ASCII.GetBytes(xmlmsg);
                if (!ch.Send(msg))
                {
                    Thread.Sleep(100);
                    continue;
                }
            }
        }
Exemplo n.º 2
0
        public IAsyncResult BeginDispatch(TimeSpan timeout, IMessage msg, object state, AsyncCallback callback)
        {
            var r = new GenericAsyncResult(state)
            {
                Callback         = callback,
                UniqueIdentifier = msg.UniqueIdentifier
            };

            _syncro.WaitOne();
            _activeMessages.Add(msg.UniqueIdentifier, r);
            _syncro.Set();

            SentMessages.Inc(1);
            var obuff = GZip.SerializeAndCompress(msg);

            SentBytes.Inc((ulong)obuff.GetLength(0));
            _outChannel.Send(obuff);
            return(r);
        }
Exemplo n.º 3
0
 private bool InChannelMessageReceived(byte[] data)
 {
     try
     {
         ReceivedMessages.Inc(1);
         ReceivedBytes.Inc((ulong)data.GetLength(0));
         var message = (OpaqueMessage.OpaqueMessage)GZip.DecompressAndDeserialize(data);
         if (message == null)
         {
             return(false);
         }
         _dispatcher.Dispatch(message);
         var outbuff = GZip.SerializeAndCompress(new OpaqueMessageReply(message));
         _outChannel.Send(outbuff);
         SentBytes.Inc((ulong)outbuff.GetLength(0));
         return(true);
     }
     catch (Exception e)
     {
         STrace.Exception(GetType().FullName, e);
     }
     return(false);
 }