예제 #1
0
    public bool Init(int port = 0, int maxConnections = 16)
    {
        var config = new UnityEngine.Networking.GlobalConfig();

        config.ThreadAwakeTimeout = 1;
        UnityEngine.Networking.NetworkTransport.Init(config);

        m_ReadBuffer = new byte[NetworkConfig.maxPackageSize + 1024];

        m_ConnectionConfig           = new ConnectionConfig();
        m_ConnectionConfig.SendDelay = 0;

        m_ChannelUnreliable = m_ConnectionConfig.AddChannel(QosType.Unreliable);
        m_Topology          = new HostTopology(m_ConnectionConfig, maxConnections);

        if (UnityEngine.Debug.isDebugBuild && m_isNetworkSimuationActive)
        {
            m_HostId = NetworkTransport.AddHostWithSimulator(m_Topology, 1, 300, port);
        }
        else
        {
            m_HostId = NetworkTransport.AddHost(m_Topology, port);
        }

        if (m_HostId != -1 && port != 0)
        {
            GameDebug.Log("Listening on " + string.Join(", ", NetworkUtils.GetLocalInterfaceAddresses()) + " on port " + port);
        }

        return(m_HostId != -1);
    }
 public GlobalConfigInternal(GlobalConfig config)
 {
     this.InitWrapper();
     this.InitThreadAwakeTimeout(config.ThreadAwakeTimeout);
     this.InitReactorModel((byte) config.ReactorModel);
     this.InitReactorMaximumReceivedMessages(config.ReactorMaximumReceivedMessages);
     this.InitReactorMaximumSentMessages(config.ReactorMaximumSentMessages);
     this.InitMaxPacketSize(config.MaxPacketSize);
 }
예제 #3
0
        // Use this for initialization
        void Awake()
        {
            ScreenLog.Write("WebManager Awake!");

            var global = new GlobalConfig();

            Debug.Log("global recieve " + global.ReactorMaximumReceivedMessages);
            Debug.Log("global sent " + global.ReactorMaximumSentMessages);
            Debug.Log("global max " + global.MaxPacketSize);
            Debug.Log("global model " + global.ReactorModel);
            Debug.Log("global thread timeout " + global.ThreadAwakeTimeout);

            global.ReactorMaximumReceivedMessages = 50000;

            NetworkTransport.Init(global);

            var config = new ConnectionConfig();
            //config.PacketSize = PACKET_SIZE;
            config.Channels.Add(new ChannelQOS(QosType.ReliableFragmented));
            config.Channels.Add(new ChannelQOS(QosType.Unreliable));


            Debug.Log("AckDelay " + config.AckDelay);
            Debug.Log("AllCostTimeout " + config.AllCostTimeout);
            Debug.Log("ChannelCount " + config.ChannelCount);
            Debug.Log("ConnectTimeout " + config.ConnectTimeout);
            Debug.Log("DisconnectTimeout " + config.DisconnectTimeout);
            Debug.Log("FragmentSize " + config.FragmentSize);
            Debug.Log("IsAcksLong " + config.IsAcksLong);
            Debug.Log("MaxCombinedReliableMessageCount " + config.MaxCombinedReliableMessageCount);
            Debug.Log("MaxCombinedReliableMessageSize " + config.MaxCombinedReliableMessageSize);
            Debug.Log("MaxConnectionAttempt " + config.MaxConnectionAttempt);
            Debug.Log("MaxSentMessageQueueSize " + config.MaxSentMessageQueueSize);
            Debug.Log("MinUpdateTimeout " + config.MinUpdateTimeout);
            Debug.Log("NetworkDropThreshold " + config.NetworkDropThreshold);
            Debug.Log("OverflowDropThreshold " + config.OverflowDropThreshold);
            Debug.Log("PacketSize " + config.PacketSize);
            Debug.Log("PingTimeout " + config.PingTimeout);
            Debug.Log("ReducedPingTimeout " + config.ReducedPingTimeout);
            Debug.Log("ResendTimeout " + config.ResendTimeout);
            Debug.Log("UsePlatformSpecificProtocols " + config.UsePlatformSpecificProtocols);

            var topology = new HostTopology(config, 200);
            topology.ReceivedMessagePoolSize = 50000;
            //topology.SentMessagePoolSize = 50000;

            if (Application.platform != RuntimePlatform.WebGLPlayer &&
                (SystemInfo.graphicsDeviceID == 0 || forceServer))
            {
                ScreenLog.Write("Server starting!");
                IsServer = true;

                server = new WebServer(19219, 8123, topology);

                ChunkManager.Instance.LoadChunks("server.vox");
                server.RefreshMap();

            }
            else
            {
                ScreenLog.Write("Client starting!");
                client = new WebClient(topology);
#if UNITY_WEBGL
                //client.TryConnect("127.0.0.1", 8123);
                client.TryConnect("188.226.164.147", 8123);
#else
                //client.TryConnect("127.0.0.1", 19219);
                client.TryConnect("188.226.164.147", 19219);
#endif
            }
        }
예제 #4
0
 public static void Init(GlobalConfig config)
 {
     NetworkTransport.InitWithParameters(new GlobalConfigInternal(config));
 }
예제 #5
0
 public static void Init(GlobalConfig config)
 {
     InitWithParameters(new GlobalConfigInternal(config));
 }