예제 #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();
 }
예제 #2
0
파일: Buffer.cs 프로젝트: chrisa23/Fibrous
 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);
         }
     }
 }
예제 #3
0
 protected override void OnError(Exception obj) => _error.Publish(obj);
예제 #4
0
 public void Publish(TIn msg) => _input.Publish(msg);
예제 #5
0
 public void Publish(T msg)
 {
     _channel.Publish(msg);
 }
예제 #6
0
 /// <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)));
 }
예제 #7
0
 public bool Publish(T msg)
 {
     return(_channel.Publish(msg));
 }