Пример #1
0
        private void TaskClientDataSub(CancellationToken cancelToken, BlockingCollection <object> queue, string bind)
        {
            using (var subSocket = new SubscriberSocket())
            {
                subSocket.Options.ReceiveHighWatermark = 50;
                subSocket.Bind(bind);
                subSocket.Subscribe("");

                while (!cancelToken.IsCancellationRequested)
                {
                    var messageTopicReceived = subSocket.ReceiveFrameString();
                    int bytesReceived        = 0;
                    switch (messageTopicReceived)
                    {
                    case "ClientHeartbeat":
                        ClientHeartbeat clientHeartbeat = subSocket.Deserialise <ClientHeartbeat>(out bytesReceived);
                        serverStatistics.DataBytesReceived += bytesReceived;
                        CheckAndAddIfNewClient(clientHeartbeat);
                        break;

                    case "ClientPositionUpdate":
                        ClientPositionUpdate clientPositionUpdate = subSocket.Deserialise <ClientPositionUpdate>(out bytesReceived);
                        serverStatistics.DataBytesReceived += bytesReceived;
                        CheckAndAddIfNewClient(clientPositionUpdate);
                        UpdateMobileClientPosition(clientPositionUpdate);
                        break;

                    case "ClientFrequencyUpdate":
                        ClientFrequencyUpdate clientFrequencyUpdate = subSocket.Deserialise <ClientFrequencyUpdate>(out bytesReceived);
                        serverStatistics.DataBytesReceived += bytesReceived;
                        CheckAndAddIfNewClient(clientFrequencyUpdate);
                        UpdateMobileClientFrequency(clientFrequencyUpdate);
                        break;
                    }
                }
                taskClientDataSub = null;
            }
        }
Пример #2
0
        private void TaskAudioSub(CancellationToken cancelToken, BlockingCollection <ClientAudio> outputQueue, string address)
        {
            using (var subSocket = new SubscriberSocket())
            {
                //subSocket.Options.ReceiveHighWatermark = 1000;
                subSocket.Connect(address);
                subSocket.Subscribe(callsign);

                while (!cancelToken.IsCancellationRequested)
                {
                    var         messageTopicReceived = subSocket.ReceiveFrameString(); //Should always == _username
                    int         bytesReceived        = 0;
                    ClientAudio clientAudio          = subSocket.Deserialise <ClientAudio>(out bytesReceived);
                    ClientStatistics.AudioBytesReceived += bytesReceived;
                    outputQueue.Add(clientAudio);
                }
            }
            taskAudioSub = null;
        }
Пример #3
0
        private void TaskDataSub(CancellationToken cancelToken, string address)
        {
            using (var subSocket = new SubscriberSocket())
            {
                //subSocket.Options.ReceiveHighWatermark = 10;
                subSocket.Connect(address);
                subSocket.Subscribe("");

                while (!cancelToken.IsCancellationRequested)
                {
                    var messageTopicReceived = subSocket.ReceiveFrameString();
                    //var messageReceived = subSocket.ReceiveFrameBytes();

                    switch (messageTopicReceived)
                    {
                    case "AdminInfo":
                        LastReceivedAdminInfo = subSocket.Deserialise <AdminInfo>();
                        break;
                    }
                }
            }
            taskDataSub = null;
        }