예제 #1
0
 /// <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>>();
 }
예제 #2
0
 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;
 }
예제 #3
0
 /// <summary>
 /// NetClient constructor
 /// </summary>
 /// <param name="config"></param>
 public NetClient(NetPeerConfiguration config)
     : base(config)
 {
     config.AcceptIncomingConnections = false;
 }
예제 #4
0
        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
            }
        }
예제 #5
0
 /// <summary>
 /// NetServer constructor
 /// </summary>
 public NetServer(NetPeerConfiguration config)
     : base(config)
 {
     config.AcceptIncomingConnections = true;
 }
예제 #6
0
        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());
        }