public void UpdateItems()
    {
        // Create list of connected and loaded microphones without duplicates.
        // A loaded microphone might have been created with hardware that is not connected now.
        List <string>                 connectedMicNames       = Microphone.devices.ToList();
        List <MicProfile>             loadedMicProfiles       = SettingsManager.Instance.Settings.MicProfiles;
        List <MicProfile>             micProfiles             = new List <MicProfile>(loadedMicProfiles);
        List <ConnectedClientHandler> connectedClientHandlers = ServerSideConnectRequestManager.GetConnectedClientHandlers();

        // Create mic profiles for connected microphones that are not yet in the list
        foreach (string connectedMicName in connectedMicNames)
        {
            bool alreadyInList = micProfiles.AnyMatch(it => it.Name == connectedMicName && !it.IsInputFromConnectedClient);
            if (!alreadyInList)
            {
                MicProfile micProfile = new MicProfile(connectedMicName);
                micProfiles.Add(micProfile);
            }
        }

        // Create mic profiles for connected companion apps that are not yet in the list
        foreach (ConnectedClientHandler connectedClientHandler in connectedClientHandlers)
        {
            bool alreadyInList = micProfiles.AnyMatch(it => it.ConnectedClientId == connectedClientHandler.ClientId && it.IsInputFromConnectedClient);
            if (!alreadyInList)
            {
                MicProfile micProfile = new MicProfile(connectedClientHandler.ClientName, connectedClientHandler.ClientId);
                micProfiles.Add(micProfile);
            }
        }

        Items = micProfiles;
    }
Beispiel #2
0
    private void UpdateConnectedClientCountText()
    {
        string connectedClientNamesCsv = ServerSideConnectRequestManager.ConnectedClientCount > 0
            ? ServerSideConnectRequestManager.GetConnectedClientHandlers()
                                         .Select(it => it.ClientName)
                                         .ToCsv(", ", "", "")
            : "";

        uiText.text = $"Connected Clients: {ServerSideConnectRequestManager.ConnectedClientCount}\n"
                      + connectedClientNamesCsv;
    }