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; }
/// <summary> /// Open room button pressed. /// /// Opens a room / starts a server /// </summary> public void OpenRoomButtonPressed() { Setup(); EnsureLength(); mNetwork.StartServer(uRoomName.text); Debug.Log("StartServer " + uRoomName.text); }
public void CreateChannel() { Setup(); if (mNetwork != null) { mNetwork.StartServer(channel); Debug.Log("StartServer: " + channel); } }
// ================================================ // NETWORK API // ================================================ /// <summary> /// Starts the server with a given server name on this node /// </summary> /// <param name="name">The name of the server to be started</param> /// <param name="callback">Callback for whether the server could start</param> /// <returns>If a server can be started</returns> public bool StartServer(string name, Action <bool> callback) { if (m_Network == null) { return(false); } m_StartServerCallback = callback; m_Network.StartServer(name); return(true); }
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(); }
public void OpenRoom() { if (mNetwork is WebRtcNetwork) { ((WebRtcNetwork)mNetwork).StartServer(uRoomName.text); } else { mNetwork.StartServer(); } Debug.Log("StartServer " + uRoomName.text); }
// 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 P2PServer(string signalingServer, string roomName) { this.roomName = roomName; lastTimeGotAnything = DateTime.Now; 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.StartServer(roomName); }
// Update is called once per frame public void UpdateServer() { frameCount++; if (!mIsServer && frameCount % 50000 == 0) { mNetwork.StartServer(roomName); } // It has been 40 seconds since got any messages, reset server before it decides to die if ((DateTime.Now - lastTimeGotAnything).TotalSeconds > 40) { PrintDebug("Server timeout after 40 seconds, restarting server"); if (mIsServer) { mNetwork.StopServer(); } mIsServer = false; mNetwork.StartServer(roomName); lastTimeGotAnything = DateTime.Now; } HandleNetwork(); }
public void OnCreateRoomClicked() { Setup(); // All players will connect to the same room for now TODO const string chars = "abcdefghijklmnopqrstuvwxyz0123456789"; System.Random rand = new System.Random(); string roomName = ""; for (int i = 0; i < 6; i++) { roomName += chars[rand.Next(chars.Length)]; } mNetwork.StartServer(roomName); Debug.Log("StartServer " + roomName); }
public void Create(string name) { Init(); network.StartServer(name); }
/// <summary> /// Starts a server for the given address /// </summary> /// <param name="addr">Address at which the server will run</param> public void StartServer(string addr) => network.StartServer(addr);