예제 #1
0
        public async void HandleCallControllerMessage(ushort groupId, byte[] packetData, int length)
        {
            var endPoint = _groupCallControllerLookup.LookupEndPoint(groupId);

            if (endPoint == null)
            {
                Console.Error.WriteLine($"No Call controller available for group {groupId}");
                return;
            }
            var keyInfo = await _keysClient.GetGroupKey(groupId);

            if (keyInfo == null)
            {
                Console.Error.WriteLine($"Could not forward message to send CallController because key is not available for group {groupId}");
                return;
            }
            _ropuProtocol.SendGroupPacket(packetData, length, endPoint, groupId, keyInfo);
        }
예제 #2
0
        public async Task StartCall(uint userId)
        {
            if (_callInProgress)
            {
                Console.WriteLine($"Called start requested for group {_groupId} by {userId} but call is already in progress");
                return;
            }
            _callInProgress = true;
            _talker         = userId;
            _callInitiator  = userId;

            var keyInfo = await _keysClient.GetGroupKey(_groupId);

            while (keyInfo == null)
            {
                Console.Error.WriteLine($"Failed to get key for group {_groupId}");
                await Task.Delay(1000);

                keyInfo = await _keysClient.GetGroupKey(_groupId);
            }
            _keyInfo = keyInfo;

            var endPointsReader = _servingNodes.EndPoints;

            _ropuProtocol.SendFloorTaken(_talker.Value, _groupId, endPointsReader.GetSnapShot(), _keyInfo);
            endPointsReader.Release();

            Console.WriteLine($"Called started with group {_groupId} initiator {userId}");

            _callCancellationTokenSource = new CancellationTokenSource();

            var cancellationToken = _callCancellationTokenSource.Token;
            var idleTask          = RunIdleTimer(cancellationToken);
            var updatesTask       = RunPeriodicUpdates(cancellationToken);
            await Task.WhenAll(idleTask, updatesTask);
        }