Ejemplo n.º 1
0
    /// <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();
        }
    }
Ejemplo n.º 2
0
 public void HostGame()
 {
     //broadcast i am server :D
     _discovery.StartAsServer();
     //start server over this ip
     StartHost();
 }
Ejemplo n.º 3
0
 public void BeginBroadcast()
 {
     if (netDiscover.running)
     {
         EndBroadcast();
     }
     netDiscover.StartAsServer();
     netDiscover.broadcastData = Network.player.ipAddress;
 }
Ejemplo n.º 4
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();
        }
    }
Ejemplo n.º 5
0
 public void CrearUnaPartida()
 {
     StopDiscovery();
     myNetworkDiscovery.StartAsServer();
     NetworkManager.singleton.StartHost();
 }
Ejemplo n.º 6
0
 public void StartLocalBroadcast()
 {
     localNetworkDiscovery = GetComponent <MyNetworkDiscovery>();
     localNetworkDiscovery.Initialize();
     localNetworkDiscovery.StartAsServer();
 }