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; }
public IBasicNetwork CreateDefault(string websocketUrl, IceServer[] urls = null) { IBasicNetwork network = mFactory.CreateDefault(websocketUrl, urls); mCreatedNetworks.Add(network); return(network); }
// 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"); } }
private void Cleanup() { if (mNetwork != null) { mNetwork.Dispose(); mNetwork = null; } }
public override void Disconnect() { if (_webrtcNetwork != null) { _webrtcNetwork.Dispose(); _webrtcNetwork = null; } base.Disconnect(); }
/// <summary> /// Deinitializes the inner network /// </summary> /// <returns>Whether the deinitialization can be done</returns> public bool Deinit() { if (m_Network != null) { m_Network.Dispose(); m_Network = null; NodeState = State.Uninitialized; return(true); } return(false); }
private void Setup() { mNetwork = WebRtcNetworkFactory.Instance.CreateDefault(signalingUrl, new string[] { stunServer }); if (mNetwork != null) { //Debug.Log("WebRTCNetwork created"); } else { Debug.Log("Failed to access WebRTC"); } }
public override void Connect() { _webrtcNetwork = WebRtcNetworkFactory.Instance.CreateDefault( _network.SignallingServer, _network.IceServers.Select(a => a.BynIce).ToArray() ); _webrtcNetwork.StartServer(_sessionId); Log.Debug("Hosting WebRTC Session: {0}", _sessionId); base.Connect(); }
private void Cleanup() { if (mNetwork != null) { if (mIsServer) { mNetwork.StopServer(); mIsServer = false; } mNetwork.Dispose(); mNetwork = null; } }
// Crea una sala de streaming... public void InitStreaming() { // Si no hay servidor creado.... if (!mIsServer) { // 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) }); // Crea una sala cuyo nombre será el del jugador... mNetwork.StartServer(GetComponent <PlayerCode>().GetName().ToString()); // Inicializa la textura y el componente de audio para recibir los datos... CreateImageAndVoice(); } }
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); }
private void Setup() { Debug.Log("Initializing webrtc network"); mNetwork = WebRtcNetworkFactory.Instance.CreateDefault(uSignalingUrl, new IceServer[] { new IceServer(uIceServer, uIceServerUser, uIceServerPassword), new IceServer(uIceServer2) }); if (mNetwork != null) { Debug.Log("WebRTCNetwork created"); } else { Debug.Log("Failed to access webrtc "); } batch = new List <Message> (); }
private void Setup() { Append("Initializing webrtc network"); mNetwork = WebRtcNetworkFactory.Instance.CreateDefault(uSignalingUrl, new IceServer[] { new IceServer(uIceServer, uIceServerUser, uIceServerPassword), new IceServer(uIceServer2) }); if (mNetwork != null) { Append("WebRTCNetwork created"); } else { Append("Failed to access webrtc "); } SetGuiState(false); }
void Init() //why WebRtcNetworkFactory.Instance must be called at start? { network = WebRtcNetworkFactory.Instance.CreateDefault( //why it tries to connect on destroy? signalingUrl, new IceServer[] { new IceServer( iceServer, iceServerUser, iceServerPassword), new IceServer(iceServer2) }); Observable .EveryFixedUpdate() .Subscribe(_ => HandleEvents()); }
/// <summary> /// Initializes the inner network /// </summary> /// <returns>Whether the initialization was successful</returns> public bool Init() { Deinit(); ConnectionIds = new List <ConnectionId>(); m_Network = WebRtcNetworkFactory.Instance.CreateDefault( k_SignallingServer, new[] { new IceServer(k_ICEServer1), new IceServer(k_ICEServer2) } ); var result = m_Network != null; if (result) { NodeState = State.Uninitialized; } else { NodeState = State.Idle; } return(m_Network != null); }
private void Setup() { Append("Initializing webrtc network"); string signalingUrl = uSignalingUrl; if (Application.platform == RuntimePlatform.WebGLPlayer || uForceSecureSignaling) { signalingUrl = uSecureSignalingUrl; } List <IceServer> iceServers = new List <IceServer>(); if (string.IsNullOrEmpty(uIceServer) == false) { iceServers.Add(new IceServer(uIceServer, uIceServerUser, uIceServerPassword)); } if (string.IsNullOrEmpty(uIceServer2) == false) { iceServers.Add(new IceServer(uIceServer2)); } if (string.IsNullOrEmpty(signalingUrl)) { throw new InvalidOperationException("set signaling url is null or empty"); } mNetwork = WebRtcNetworkFactory.Instance.CreateDefault(signalingUrl, iceServers.ToArray()); if (mNetwork != null) { Append("WebRTCNetwork created"); } else { Append("Failed to access webrtc "); } SetGuiState(false); }
void Start() { DebugHelper.ActivateConsole(); if (WebRtcNetwork.IsAvailable() == false) { //if the libray isn't available this could mean the JS part of the library is missing //(wrong template, webrtcnetworplugin.js not included -> try adding it via ExternalEval) Append("Try to initialize WebRTCNetwork"); WebRtcNetwork.InjectJsCode(); } if (WebRtcNetwork.IsAvailable()) { //default version //mNetwork = new WebRtcNetwork(); //custom configuration mNetwork = new WebRtcNetwork(mWebRtcConfig); Append("WebRtcNetwork available"); } else { Append("WebRtcNetwork not available"); if (UnityNetwork.IsAvailable()) { mNetwork = UnityNetwork.Get(); Append("Using unity network instead. TESTING ONLY! You can't connect to browsers."); Append("Build a WebGL example to use WebRTC!"); } else { Append("No network module available. Build and run a WebGL version or switch the platform to Standalone to use the Debugversion."); } } }
//Not available at all in WebGL. All calls just map into a java script library //thus a signaling network would need to be implemeted in java script public ICall CreateCall(NetworkConfig config, IBasicNetwork signalingNetwork) { throw new NotSupportedException("Custom signaling networks are not supported in WebGL. It needs to be implemented in java script."); }
private void Start() { DebugHelper.ActivateConsole(); if(WebRtcNetwork.IsAvailable() == false) { //if the libray isn't available this could mean the JS part of the library is missing //(wrong template, webrtcnetworplugin.js not included -> try adding it via ExternalEval) Append("Try to initialize WebRTCNetwork"); WebRtcNetwork.InjectJsCode(); } if (WebRtcNetwork.IsAvailable()) { //default version //mNetwork = new WebRtcNetwork(); //custom configuration mNetwork = new WebRtcNetwork(mWebRtcConfig); Append("WebRtcNetwork available"); } else { Append("WebRtcNetwork not available"); if(UnityNetwork.IsAvailable()) { mNetwork = UnityNetwork.Get(); Append("Using unity network instead. TESTING ONLY! You can't connect to browsers."); Append("Build a WebGL example to use WebRTC!"); } else { Append("No network module available. Build and run a WebGL version or switch the platform to Standalone to use the Debugversion."); } } }
void Cleanup() { network?.Dispose(); network = null; }