public bool Init(uint16_t inPort, bool reBind = false) { if (inPort == 0) { // client NetPeerConfiguration config = new NetPeerConfiguration("game"); //config.AutoFlushSendQueue = false; mNetPeer = new NetClient(config); } else { // server NetPeerConfiguration config = new NetPeerConfiguration("game"); config.MaximumConnections = 1000; config.Port = inPort; mNetPeer = new NetServer(config); } mNetPeer.Start(); //LOG("Initializing NetworkManager at port %d", inPort); mBytesReceivedPerSecond = new WeightedTimedMovingAverage(1.0f); mBytesSentPerSecond = new WeightedTimedMovingAverage(1.0f); return(true); }
public void Init(System.Net.IPEndPoint inServerAddress, string inName, byte inWorldId) { base.Init(core.World.DefaultWorldCount); // client NetPeerConfiguration config = new NetPeerConfiguration("game", inServerAddress.AddressFamily); #if DEBUG // 디버깅 환경에서 타임 아웃 처리 조정 config.ConnectionTimeout = 300f; //if (Configuration.Instance.EnableLatencySimulation) //{ // config.SimulatedLoss = Configuration.Instance.SimulatedLoss; // config.SimulatedRandomLatency = Configuration.Instance.SimulatedRandomLatency; // config.SimulatedMinimumLatency = Configuration.Instance.SimulatedMinimumLatency; // config.SimulatedDuplicatesChance = Configuration.Instance.SimulatedDuplicatesChance; //} #endif //config.AutoFlushSendQueue = false; mNetPeer = new NetClient(config); mNetPeer.Start(); mDeliveryNotificationManager = new core.DeliveryNotificationManager(true, false); mReplicationManagerClient = new ReplicationManagerClient(); algo = new NetXorEncryption(GetClient(), "AceTopSecret"); mLastRoundTripTime = 0.0f; mTimeOfLastInputPacket = 0f; mServerAddress = inServerAddress; mState = NetworkClientState.SayingHello; mTimeOfLastHello = 0.0f; mTimeOfLastStartPlay = 0.0f; mName = inName; mWorldId = inWorldId; tryConnectCount = 0; mAvgRoundTripTime = new core.WeightedTimedMovingAverage(1.0f); NetOutgoingMessage hail = GetClient().CreateMessage("hail"); GetClient().Connect(mServerAddress, hail); IsTcp = false; IsUdpOk = false; IsTrySend = true; respawn = false; // tcp SetConnector(inServerAddress); LinkedObject.Clear(); }
void Init(System.Net.IPEndPoint inServerAddress, string inName) { base.Init(0); mServerAddress = inServerAddress; mState = NetworkClientState.NCS_SayingHello; mTimeOfLastHello = 0.0f; mName = inName; mAvgRoundTripTime = new core.WeightedTimedMovingAverage(1.0f); NetOutgoingMessage hail = GetClient().CreateMessage("hail"); GetClient().Connect(mServerAddress, hail); }
public void Init(byte worldCount) { if (worldCount > 0) { mNetworkIdToGameObjectMap = new Dictionary <int, NetGameObject> [worldCount]; for (int i = 0; i < worldCount; ++i) { mNetworkIdToGameObjectMap[i] = new Dictionary <int, NetGameObject>(); } } mBytesReceivedPerSecond = new WeightedTimedMovingAverage(1.0f); mBytesSentPerSecond = new WeightedTimedMovingAverage(1.0f); }