Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        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;
        }