public void Publish(string topic, byte[] content) { var pInfo = new PublishInfo() { Name = _name, Topic = topic, Data = content }; SendAsyncBase(QueueSocketMsgType.Publish, pInfo.ToBytes()); }
public void PublishList(List <Tuple <string, byte[]> > data) { if (data == null) { return; } var list = new List <byte[]>(); data.ForEach(item => { var pInfo = new PublishInfo() { Name = _name, Topic = item.Item1, Data = item.Item2 }; list.Add(pInfo.ToBytes()); }); SendBase(QueueSocketMsgType.PublishForBatch, list.ToBytes()); }
public void PublishAsync(string topic, byte[] content, int maxNum = 500, int maxTime = 500) { var pInfo = new PublishInfo() { Name = _name, Topic = topic, Data = content }; var cdata = pInfo.ToBytes(); lock (_locker) { if (_batchProcess == null) { _batchProcess = new BatchProcess <byte[]>((data) => { SendBase(QueueSocketMsgType.PublishForBatch, data.ToBytes()); }, maxNum, maxTime); } } _batchProcess.Package(cdata); }