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(); }
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); } } }
protected override void OnError(Exception obj) => _error.Publish(obj);
public void Publish(TIn msg) => _input.Publish(msg);
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))); }
public bool Publish(T msg) { return(_channel.Publish(msg)); }