Beispiel #1
0
 public void BeginListening()
 {
     if (netDiscover.running)
     {
         EndBroadcast();
     }
     netDiscover.StartAsClient();
 }
Beispiel #2
0
    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();
        }
    }
Beispiel #3
0
    /// <summary>
    /// Start as client and if discovery not running, start broadcast receive mode.
    /// </summary>
    public void SetupClient()
    {
        Debug.Log("SetupClient()");

        ConnectionConfig config = new ConnectionConfig();

        config.AddChannel(QosType.ReliableSequenced);
        config.AddChannel(QosType.Unreliable);
        myClient.Configure(config, 1000);

        discovery.Initialize();
        discovery.StartAsClient();

        // Register message event handler
        myClient.RegisterHandler(MsgType.Connect, OnConnected);
        myClient.RegisterHandler(MsgType.Disconnect, OnDisconnected);
        myClient.RegisterHandler(MyMsgType.Custom, OnCustomMessage);
    }
Beispiel #4
0
    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;
    }
Beispiel #5
0
 public void UnirseUnaPartida()
 {
     StopDiscovery();
     myNetworkDiscovery.StartAsClient();
 }
Beispiel #6
0
 public void SearchGame()
 {
     //start search for servers over network
     _discovery.StartAsClient();
 }
Beispiel #7
0
 public void StartReceiveLocalBroadcast()
 {
     localNetworkDiscovery = GetComponent <MyNetworkDiscovery>();
     localNetworkDiscovery.Initialize();
     localNetworkDiscovery.StartAsClient();
 }