/// <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(); } }
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(); } }
private void Awake() { Team = Team.None; if (Instance != null) { Debug.Log(Util.C($"Multiple NetworkControllers!!!", Color.red)); throw new Exception(); } Instance = this; discovery.Register(this); discovery.Initialize(); Debug.Log("Discovery as client in awake"); discovery.StartAsClient(); manager.Register(this); inputListeners = new HashSet <InputListener>(); broadcastTable = new Dictionary <string, Team>(); InitHostHandlers(); InitAndRegisterSpawnable(); DontDestroyOnLoad(this); gameState = GameState.Lobby; }
private void Start() { _discovery = GetComponent <MyNetworkDiscovery>(); //this require on network discovery _discovery.Initialize(); }
private void Start() { lobbyPlayers = new List <LobbyPlayers>(); netDiscover.Initialize(); //servers.options = netDiscover.broadcastsReceived; }
public void StartReceiveLocalBroadcast() { localNetworkDiscovery = GetComponent <MyNetworkDiscovery>(); localNetworkDiscovery.Initialize(); localNetworkDiscovery.StartAsClient(); }
public void StartLocalBroadcast() { localNetworkDiscovery = GetComponent <MyNetworkDiscovery>(); localNetworkDiscovery.Initialize(); localNetworkDiscovery.StartAsServer(); }