/// <summary> /// NetPeer constructor /// </summary> public NetPeer(NetPeerConfiguration config) { m_configuration = config; m_statistics = new NetPeerStatistics(this); m_releasedIncomingMessages = new NetQueue<NetIncomingMessage>(4); m_unsentUnconnectedMessages = new NetQueue<NetTuple<NetEndPoint, NetOutgoingMessage>>(2); m_connections = new List<NetConnection>(); m_connectionLookup = new Dictionary<NetEndPoint, NetConnection>(); m_handshakes = new Dictionary<NetEndPoint, NetConnection>(); m_senderRemote = (EndPoint)new NetEndPoint(IPAddress.Any, 0); m_status = NetPeerStatus.NotRunning; m_receivedFragmentGroups = new Dictionary<NetConnection, Dictionary<int, ReceivedFragmentGroup>>(); }
internal NetConnection(NetPeer peer, NetEndPoint remoteEndPoint) { m_peer = peer; m_peerConfiguration = m_peer.Configuration; m_status = NetConnectionStatus.None; m_outputtedStatus = NetConnectionStatus.None; m_visibleStatus = NetConnectionStatus.None; m_remoteEndPoint = remoteEndPoint; m_sendChannels = new NetSenderChannelBase[NetConstants.NumTotalChannels]; m_receiveChannels = new NetReceiverChannelBase[NetConstants.NumTotalChannels]; m_queuedOutgoingAcks = new NetQueue<NetTuple<NetMessageType, int>>(4); m_queuedIncomingAcks = new NetQueue<NetTuple<NetMessageType, int>>(4); m_statistics = new NetConnectionStatistics(this); m_averageRoundtripTime = -1.0f; m_currentMTU = m_peerConfiguration.MaximumTransmissionUnit; }
/// <summary> /// NetClient constructor /// </summary> /// <param name="config"></param> public NetClient(NetPeerConfiguration config) : base(config) { config.AcceptIncomingConnections = false; }
void Create(string nomJeu, int port) { try { Config = new NetPeerConfiguration(NomJeu); Config.Port = Port; Config.MaximumConnections = 2; Config.EnableMessageType(NetIncomingMessageType.ConnectionApproval); Serveur = new NetServer(Config); Serveur.Start(); Temps = DateTime.Now; Console.WriteLine("Serveur démaré" + Temps.ToString()); } catch(Exception) { Console.WriteLine("Exception Serveur"); throw new Exception(""); //Envoie de l'exception vers network manager } }
/// <summary> /// NetServer constructor /// </summary> public NetServer(NetPeerConfiguration config) : base(config) { config.AcceptIncomingConnections = true; }
void Create(string nomJeu, int port) { // Demande l'ip si aucune adresse n'a été fournie if (HostIP == null) { ConsoleWindow.ShowConsoleWindow(); Console.WriteLine("Enter IP To Connect"); HostIP = Console.ReadLine(); ConsoleWindow.HideConsoleWindow(); } //Crée la configuration du client -> doit avoir le même nom que le serveur NetPeerConfiguration Config = new NetPeerConfiguration(NomJeu); Client = new NetClient(Config); Client.Start(); Temps = DateTime.Now; Console.WriteLine("Client créé à " + Temps.ToString()); }