Exemplo n.º 1
0
    public void JoinLobbyChannel(string channelName)
    {
        Debug.Log("Attempting to join: " + channelName);
        if (_currentChannel != null)
        {
            return;
        }

        _currentChannel = channelName;
        var lobbychannel = _vivoxVoiceManager.ActiveChannels.FirstOrDefault(ac => ac.Channel.Name == _vivoxNetworkManager.LobbyChannelName);

        if ((_vivoxVoiceManager && _vivoxVoiceManager.ActiveChannels.Count == 0) ||
            lobbychannel == null)
        {
            Debug.Log("I'm in");
            _vivoxVoiceManager.OnParticipantAddedEvent += VivoxVoiceManager_OnParticipantAddedEvent;
            _vivoxVoiceManager.JoinChannel(channelName, ChannelType.NonPositional, VivoxVoiceManager.ChatCapability.TextAndAudio);
        }
        else
        {
            Debug.Log("Elsed");
            if (lobbychannel.AudioState == ConnectionState.Disconnected)
            {
                Debug.Log("Elsed2");
                // Ask for hosts since we're already in the channel and part added won't be triggered.
                _vivoxNetworkManager.SendLobbyUpdate(VivoxNetworkManager.MatchStatus.Seeking);

                lobbychannel.BeginSetAudioConnected(true, true, ar =>
                {
                    Debug.Log("Now transmitting into lobby channel");
                });
            }
        }
        // Do nothing, participant added will take care of this
    }
 private void VivoxVoiceManager_OnParticipantAddedEvent(string username, ChannelId channel, IParticipant participant)
 {
     if (channel.Name == _vivoxNetworkManager.LobbyChannelName && participant.IsSelf)
     {
         // if joined the lobby channel and we're not hosting a match
         // we should request invites from hosts
         _vivoxNetworkManager.SendLobbyUpdate(VivoxNetworkManager.MatchStatus.Seeking);
     }
 }
 private void HostMatch()
 {
     // StartHost must fire before SendLobbyUpdate
     _vivoxNetworkManager.StartHost();
     _vivoxNetworkManager.SendLobbyUpdate(VivoxNetworkManager.MatchStatus.Open);
     _vivoxNetworkManager.LeaveAllChannels();
 }
Exemplo n.º 4
0
    public void JoinLobby()
    {
        if (lobbyNameInput.gameObject.activeSelf)
        {
            vivoxNetworkManager.LobbyChannelName = lobbyNameInput.text;
        }
        else
        {
            string lobbyName = UnityEngine.Random.Range(1, 1000).ToString();
            vivoxNetworkManager.LobbyChannelName = lobbyName;
        }

        var lobbyChannel = vivoxVoiceManager.ActiveChannels.FirstOrDefault(ac => ac.Channel.Name == vivoxNetworkManager.LobbyChannelName);

        if ((vivoxVoiceManager && vivoxVoiceManager.ActiveChannels.Count == 0) || lobbyChannel == null)
        {
            JoinLobbyChannel();
        }
        else
        {
            if (lobbyChannel.AudioState == ConnectionState.Disconnected)
            {
                vivoxNetworkManager.SendLobbyUpdate(VivoxNetworkManager.MatchStatus.Seeking);

                lobbyChannel.BeginSetAudioConnected(true, true, ar =>
                {
                    Debug.Log("Now transmitting into lobby channel");
                });
            }
        }
    }
Exemplo n.º 5
0
    private void OnParticipantAdded(string userName, ChannelId channelId, IParticipant participant)
    {
        lobby.SetActive(true);
        logoutButton.interactable = true;
        lobbyName.SetText(vivoxNetworkManager.LobbyChannelName);

        if (channelId.Name == vivoxNetworkManager.LobbyChannelName && participant.IsSelf)
        {
            vivoxNetworkManager.SendLobbyUpdate(VivoxNetworkManager.MatchStatus.Seeking);
        }
    }
Exemplo n.º 6
0
 private void ConfirmYesButtonAction()
 {
     if (_vivoxNetworkManager.networkAddress == "localhost")
     {
         _vivoxNetworkManager.SendLobbyUpdate(VivoxNetworkManager.MatchStatus.Closed);
         _vivoxNetworkManager.StopHost();
     }
     else
     {
         _vivoxNetworkManager.StopClient();
     }
 }
Exemplo n.º 7
0
 public void HostMatch()
 {
     vivoxNetworkManager.StartHost();
     vivoxNetworkManager.SendLobbyUpdate(VivoxNetworkManager.MatchStatus.Open);
     vivoxNetworkManager.LeaveAllChannels();
 }