private void TaskDataPub(CancellationToken cancelToken, BlockingCollection <object> queue, string address) { using (var pubSocket = new PublisherSocket()) { //pubSocket.Options.SendHighWatermark = 1; pubSocket.Connect(address); while (!cancelToken.IsCancellationRequested) { if (queue.TryTake(out object data, 500)) { switch (data.GetType().Name) { case "ClientHeartbeat": pubSocket.Serialise <ClientHeartbeat>(data); break; case "ClientPositionUpdate": pubSocket.Serialise <ClientPositionUpdate>(data); break; case "ClientFrequencyUpdate": pubSocket.Serialise <ClientFrequencyUpdate>(data); break; } } } } taskDataPub = null; }
private void TaskClientAudioPub(CancellationToken cancelToken, BlockingCollection <Tuple <List <string>, ClientAudio> > inputQueue, string bind) { using (var pubSocket = new PublisherSocket()) { pubSocket.Options.SendHighWatermark = 100; pubSocket.Bind(bind); while (!cancelToken.IsCancellationRequested) { if (inputQueue.TryTake(out Tuple <List <string>, ClientAudio> data, 500)) { foreach (var clientID in data.Item1) { pubSocket.Serialise(clientID, data.Item2); } } } } taskClientAudioPub = null; }
private void TaskClientDataPub(CancellationToken cancelToken, BlockingCollection <object> queue, string bind) { using (var pubSocket = new PublisherSocket()) { pubSocket.Options.SendHighWatermark = 10; pubSocket.Bind(bind); while (!cancelToken.IsCancellationRequested) { if (queue.TryTake(out object data, 500)) { switch (data.GetType().Name) { case "AdminInfo": serverStatistics.DataBytesSent += pubSocket.Serialise <AdminInfo>(data); break; } } } } taskClientDataPub = null; }