Beispiel #1
0
 private void Run()
 {
     while (_running)
     {
         NetMQMessage message;
         try
         {
             message = Socket.ReceiveMessage(); //_timeout
         }
         catch (Exception e)
         {
             //This needs improvement...
             Console.WriteLine(e);
             _running = false;
             break;
         }
         if (message.IsEmpty)
         {
             continue;
         }
         T msg = _msgReceiver(message[0].Buffer);
         _output.Publish(msg);
     }
     InternalDispose();
 }
Beispiel #2
0
 private void OnReceive(T obj)
 {
     lock (this)
     {
         _buffer[_index++] = obj;
         if (_index > _size - 1)
         {
             //Find a way to use a pool or something
             //We can't know when usage is done easily
             T[] output = new T[_size];
             Array.Copy(_buffer, output, _size);
             _output.Publish(output);
         }
     }
 }
Beispiel #3
0
 protected override void OnError(Exception obj) => _error.Publish(obj);
Beispiel #4
0
 public void Publish(TIn msg) => _input.Publish(msg);
Beispiel #5
0
 public void Publish(T msg)
 {
     _channel.Publish(msg);
 }
 /// <summary>
 /// Quick way to connect a Subscriber port to a Publisher port.  Useful connecting channels and Agents
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="port"></param>
 /// <param name="fiber"></param>
 /// <param name="receive"></param>
 /// <returns></returns>
 public static IDisposable Connect <T>(this ISubscriberPort <T> port,
                                       IFiber fiber,
                                       IPublisherPort <T> receive)
 {
     return(port.Subscribe(StubFiber.StartNew(), x => receive.Publish(x)));
 }
Beispiel #7
0
 public bool Publish(T msg)
 {
     return(_channel.Publish(msg));
 }