/// <summary> /// Start as server and if discovery not running, start broadcast. /// </summary> public void SetupServer() { if (!NetworkServer.active) { Debug.Log("SetupServer( )"); ConnectionConfig config = new ConnectionConfig(); config.AddChannel(QosType.ReliableSequenced); config.AddChannel(QosType.Unreliable); NetworkServer.Configure(config, 1000); NetworkServer.dontListen = false; NetworkServer.Listen(4444); // 注册回调绑定 NetworkServer.RegisterHandler(MsgType.Connect, OnConnected); NetworkServer.RegisterHandler(MsgType.Disconnect, OnDisconnected); NetworkServer.RegisterHandler(MyMsgType.UID, OnUID); NetworkServer.RegisterHandler(MyMsgType.Custom, OnCustomMessage); } if (!discovery.running) { discovery.Initialize(); discovery.StartAsServer(); } }
public void HostGame() { //broadcast i am server :D _discovery.StartAsServer(); //start server over this ip StartHost(); }
public void BeginBroadcast() { if (netDiscover.running) { EndBroadcast(); } netDiscover.StartAsServer(); netDiscover.broadcastData = Network.player.ipAddress; }
private void OnGUI() { if (GUI.Button(new Rect(0, 0, 250, 20), "ホストとして起動")) { StartHost(); m_NetworkDiscovery.Initialize(); m_NetworkDiscovery.StartAsServer(); } if (GUI.Button(new Rect(0, 30, 250, 20), "クライアントとして接続")) { m_NetworkDiscovery.Initialize(); m_NetworkDiscovery.StartAsClient(); } }
public void CrearUnaPartida() { StopDiscovery(); myNetworkDiscovery.StartAsServer(); NetworkManager.singleton.StartHost(); }
public void StartLocalBroadcast() { localNetworkDiscovery = GetComponent <MyNetworkDiscovery>(); localNetworkDiscovery.Initialize(); localNetworkDiscovery.StartAsServer(); }