/// <summary> /// NetManager constructor /// </summary> /// <param name="listener">Network events listener</param> /// <param name="maxConnections">Maximum connections (incoming and outcoming)</param> public NetManager(INetEventListener listener, int maxConnections) { _logicThread = new Thread(UpdateLogic) { Name = "LogicThread", IsBackground = true }; _socket = new NetSocket(ReceiveLogic); _netEventListener = listener; _netEventsQueue = new SwitchQueue <NetEvent>(); _netEventsPool = new Stack <NetEvent>(); NetPacketPool = new NetPacketPool(); NatPunchModule = new NatPunchModule(this); Statistics = new NetStatistics(); _peers = new NetPeerCollection(maxConnections); _connectingPeers = new HashSet <NetEndPoint>(); _maxConnections = maxConnections; _updateTimeFilter = new long[3]; // Precreate all needed Merge Packets for (int i = 0; i < maxConnections * 3; ++i) { NetPacket p = NetPacketPool.Get(PacketProperty.Sequenced, 0, NetConstants.MaxPacketSize); p.Recycle(); } }
protected NetBase(INetEventListener listener) { _socket = new NetSocket(ReceiveLogic); _netEventListener = listener; _flowModes = new List <FlowMode>(); _netEventsQueue = new Queue <NetEvent>(); _netEventsPool = new Stack <NetEvent>(); NatPunchModule = new NatPunchModule(this, _socket); }
protected NetBase(INetEventListener listener) { _logicThread = new NetThread("LogicThread", DefaultUpdateTime, UpdateLogic); _socket = new NetSocket(ReceiveLogic); _netEventListener = listener; _flowModes = new List <FlowMode>(); _netEventsQueue = new Queue <NetEvent>(); _netEventsPool = new Stack <NetEvent>(); NatPunchModule = new NatPunchModule(this, _socket); }
protected NetBase(INetEventListener listener, ConnectionAddressType addressType) { _socket = new NetSocket(addressType); _addressType = addressType; _netEventListener = listener; _flowModes = new List <FlowMode>(); _netEventsQueue = new Queue <NetEvent>(); _netEventsPool = new Stack <NetEvent>(); _remoteEndPoint = new NetEndPoint(_addressType, 0); NatPunchModule = new NatPunchModule(this, _socket); }
/// <summary> /// NetManager constructor /// </summary> /// <param name="listener">Network events listener</param> public NetManager(INetEventListener listener) { _socket = new NetSocket(this); _netEventListener = listener; _netEventsQueue = new Queue <NetEvent>(); _netEventsPool = new Stack <NetEvent>(); NetPacketPool = new NetPacketPool(); NatPunchModule = new NatPunchModule(_socket); Statistics = new NetStatistics(); _peers = new NetPeerCollection(); _connectedPeerListCache = new List <NetPeer>(); }
/// <summary> /// NetManager constructor /// </summary> /// <param name="listener">Network events listener</param> /// <param name="maxConnections">Maximum connections (incoming and outcoming)</param> public NetManager(INetEventListener listener, int maxConnections) { _socket = new NetSocket(ReceiveLogic); _netEventListener = listener; _netEventsQueue = new Queue <NetEvent>(); _netEventsPool = new Stack <NetEvent>(); NetPacketPool = new NetPacketPool(); NatPunchModule = new NatPunchModule(_socket); Statistics = new NetStatistics(); _peers = new NetPeerCollection(); _connectingPeers = new HashSet <IPEndPoint>(new IPEndPointComparer()); _maxConnections = maxConnections; _connectedPeerListCache = new List <NetPeer>(); }
/// <summary> /// NetManager constructor /// </summary> /// <param name="listener">Network events listener</param> /// <param name="maxConnections">Maximum connections (incoming and outcoming)</param> /// <param name="connectKey">Application key (must be same with remote host for establish connection)</param> public NetManager(INetEventListener listener, int maxConnections, string connectKey) { _logicThread = new NetThread("LogicThread", DefaultUpdateTime, UpdateLogic); _socket = new NetSocket(ReceiveLogic); _netEventListener = listener; _flowModes = new List <FlowMode>(); _netEventsQueue = new Queue <NetEvent>(); _netEventsPool = new Stack <NetEvent>(); _netPacketPool = new NetPacketPool(); NatPunchModule = new NatPunchModule(this); _connectKey = connectKey; _peers = new NetPeerCollection(maxConnections); _maxConnections = maxConnections; _connectKey = connectKey; }
/// <summary> /// NetManager constructor /// </summary> /// <param name="listener">Network events listener</param> /// <param name="maxConnections">Maximum connections (incoming and outcoming)</param> public NetManager(INetEventListener listener, int maxConnections) { _logicThread = new Thread(UpdateLogic) { Name = "LogicThread", IsBackground = true }; _socket = new NetSocket(ReceiveLogic); _netEventListener = listener; _netEventsQueue = new Queue <NetEvent>(); _netEventsPool = new Stack <NetEvent>(); NetPacketPool = new NetPacketPool(); NatPunchModule = new NatPunchModule(this); Statistics = new NetStatistics(); _peers = new NetPeerCollection(maxConnections); _connectingPeers = new HashSet <NetEndPoint>(); _maxConnections = maxConnections; }
protected NetBase(INetEventListener listener) { _socket = new NetSocket(ReceiveLogic); _netEventListener = listener; _flowModes = new List<FlowMode>(); _netEventsQueue = new Queue<NetEvent>(); _netEventsPool = new Stack<NetEvent>(); NatPunchModule = new NatPunchModule(this, _socket); }