Example #1
0
    public void UpdateClient()
    {
        frameCount++;

        if (peers.Count == 0 && frameCount % 10000 == 0)
        {
            mNetwork.Connect(roomName);
        }


        HandleNetwork();
    }
Example #2
0
        public override void Connect()
        {
            _webrtcNetwork = WebRtcNetworkFactory.Instance.CreateDefault(
                _network.SignallingServer,
                _network.IceServers.Select(a => a.BynIce).ToArray()
                );

            // Connect to the master peer
            if (_network.IsServer)
            {
                Log.Debug("Connecting to WebRTC Session: {0} (loopback)", _sessionId);
                Connected();
            }
            else
            {
                Log.Debug("Connecting to WebRTC Session: {0}", _sessionId);
                _serverConnectionId = _webrtcNetwork.Connect(_sessionId);
            }

            // Start a server to listen for direct p2p connections using `SessionID:PlayerName` as the session name
            var mySession = UniquePlayerSessionId(_network.PlayerName);

            _webrtcNetwork.StartServer(mySession);
            Log.Debug("Hosting WebRTC Session: {0}", mySession);

            PlayerJoined += OnPlayerJoined;
        }
Example #3
0
    // Función para entrar a una sala....
    public void OnClickJoinStreaming(Text dir)
    {
        // Si no se encuentra añadidado ya a otra sala...
        if (!isConnectedAsClient)
        {
            // Se crea una instancia del tipo WebRtcNetworkFactory, la cual tiene las direcciones especificadas al principio del script...
            mNetwork = WebRtcNetworkFactory.Instance.CreateDefault(uSignalingUrl, new IceServer[] { new IceServer(uIceServer), new IceServer(uIceServer2) });
            // Se conecta a la sala cuyo nombre se haya extraido del botón presionado en la lista de streaming abiertos...
            mNetwork.Connect(dir.text.ToString());
            // Si la cámara o el micrófono están activos...
            if (IsRecording || isSpeaking)
            {
                // Está transimiendo...
                isTransmitter = true;
            }

            // Inicializa la textura y el componente de audio para recibir los datos...
            CreateImageAndVoice();
            Debug.Log("Entrando al streaming...");
        }
        else
        {
            Debug.Log("Ya eres miembro de una sala de streaming, no puedes abrir más conexiones");
        }
    }
Example #4
0
 /// <summary>
 /// Connects the inner client to a server identified by the name
 /// </summary>
 /// <param name="name">The name of the server to be connected to</param>
 /// <param name="callback">Whether the connection was successful</param>
 /// <returns>If the inner client can connect to a server</returns>
 public bool Connect(string name, Action <ConnectionId> callback)
 {
     if (m_Network == null)
     {
         return(false);
     }
     m_ConnectCallback = callback;
     m_Network.Connect(name);
     return(true);
 }
Example #5
0
 public void ConnectToChannel()
 {
     Setup();
     if (mNetwork != null)
     {
         //ConnectionId connect = mNetwork.Connect(channel);
         mNetwork.Connect(channel);
         Debug.Log("ConnectToServer: " + channel);
     }
 }
Example #6
0
    public P2PClient(string signalingServer, string roomName)
    {
        this.roomName = roomName;
        peers         = new Dictionary <string, ConnectionId>();
        //mNetwork = WebRtcNetworkFactory.Instance.CreateDefault("wss://nameless-scrubland-88927.herokuapp.com", new IceServer[] { new IceServer("stun:stun.l.google.com:19302") });
        mNetwork = WebRtcNetworkFactory.Instance.CreateDefault(signalingServer, new IceServer[] { new IceServer("stun:stun.l.google.com:19302") });
        if (mNetwork == null)
        {
            PrintDebug("failed to setup network");
            return;
        }

        mNetwork.Connect(roomName);
    }
Example #7
0
        private void OnPlayerJoined(string name, CodecSettings _)
        {
            if (name == _network.PlayerName)
            {
                return;
            }

            // Try to connect directly to this peer if their ID comes after yours
            // This ensures that connections are only established in one direction between any two given peers.
            if (_peerHandshake != null && string.Compare(name, _network.PlayerName, StringComparison.Ordinal) > 0)
            {
                var s = UniquePlayerSessionId(name);
                Log.Debug("Trying to establish p2p connection to `{0}`", s);
                _webrtcNetwork.Connect(s);
            }
        }
Example #8
0
 /// <summary>
 /// Join button pressed. Tries to join a room.
 /// </summary>
 public void JoinRoomButtonPressed()
 {
     Setup();
     mNetwork.Connect(uRoomName.text);
     Append("Connecting to " + uRoomName.text + " ...");
 }
Example #9
0
 public void Join()
 {
     mNetwork.Connect(uRoomName.text);
     Append("Connect to " + uRoomName.text);
 }
Example #10
0
 public void Connect(string name)
 {
     Init();
     network.Connect(name);
 }
Example #11
0
 /// <summary>
 /// Connects to a server using the address
 /// </summary>
 /// <param name="address">Address of the server to connect to</param>
 public void Connect(string address) => network.Connect(address);
Example #12
0
 private void JoinRoom(string address)
 {
     Setup();
     mNetwork.Connect(address);
     Debug.Log("Connecting to " + address + " ...");
 }