当前位置: 首页>>代码示例>>C#>>正文


C# NetPeerConfiguration.EnableMessageType方法代码示例

本文整理汇总了C#中Lidgren.Network.NetPeerConfiguration.EnableMessageType方法的典型用法代码示例。如果您正苦于以下问题:C# NetPeerConfiguration.EnableMessageType方法的具体用法?C# NetPeerConfiguration.EnableMessageType怎么用?C# NetPeerConfiguration.EnableMessageType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lidgren.Network.NetPeerConfiguration的用法示例。


在下文中一共展示了NetPeerConfiguration.EnableMessageType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetStandardConfiguration

 // Only for Introducer's NetworkServer
 public static NetPeerConfiguration GetStandardConfiguration(this NetPeerConfiguration self, int listeningPort)
 {
     var config = new NetPeerConfiguration("NovaRat");
     // Disable all message types
     config.DisableMessageType(NetIncomingMessageType.ConnectionApproval);
     config.DisableMessageType(NetIncomingMessageType.ConnectionLatencyUpdated);
     config.DisableMessageType(NetIncomingMessageType.Data);
     config.DisableMessageType(NetIncomingMessageType.DebugMessage);
     config.DisableMessageType(NetIncomingMessageType.DiscoveryRequest);
     config.DisableMessageType(NetIncomingMessageType.DiscoveryResponse);
     config.DisableMessageType(NetIncomingMessageType.Error);
     config.DisableMessageType(NetIncomingMessageType.ErrorMessage);
     config.DisableMessageType(NetIncomingMessageType.NatIntroductionSuccess);
     config.DisableMessageType(NetIncomingMessageType.Receipt);
     config.DisableMessageType(NetIncomingMessageType.UnconnectedData);
     config.DisableMessageType(NetIncomingMessageType.VerboseDebugMessage);
     config.DisableMessageType(NetIncomingMessageType.WarningMessage);
     // Enable only what we need
     config.EnableMessageType(NetIncomingMessageType.UnconnectedData);
     config.EnableMessageType(NetIncomingMessageType.NatIntroductionSuccess);
     config.EnableMessageType(NetIncomingMessageType.StatusChanged);
     //config.EnableMessageType(NetIncomingMessageType.DebugMessage);
     //config.EnableMessageType(NetIncomingMessageType.VerboseDebugMessage);
     //config.EnableMessageType(NetIncomingMessageType.WarningMessage);
     //config.EnableMessageType(NetIncomingMessageType.ErrorMessage);
     config.Port = listeningPort;
     config.AcceptIncomingConnections = true;
     return config;
 }
开发者ID:theslyone,项目名称:RemoteDesktop,代码行数:30,代码来源:NetPeerConfigurationExtensions.cs

示例2: StartDiscoveryInternal

		/// <summary>
		/// 
		/// </summary>
		/// <param name="numPorts"></param>
		/// <param name="timeout"></param>
		void StartDiscoveryInternal ( int numPorts, TimeSpan timeout )
		{
			lock (lockObj) {
				if (client!=null) {
					Log.Warning("Discovery is already started.");
					return;
				}

				this.timeout	=	timeout;

				var netConfig = new NetPeerConfiguration( Game.GameID );
				netConfig.EnableMessageType( NetIncomingMessageType.DiscoveryRequest );
				netConfig.EnableMessageType( NetIncomingMessageType.DiscoveryResponse );

				client	=	new NetClient( netConfig );
				client.Start();

				var svPort	=	Game.Network.Port;

				var ports = Enumerable.Range(svPort, numPorts)
							.Where( p => p <= ushort.MaxValue )
							.ToArray();

				Log.Message("Start discovery on ports: {0}", string.Join(", ", ports) );

				foreach (var port in ports) {
					client.DiscoverLocalPeers( port );
				}
			}
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:35,代码来源:UserInterface.Internal.cs

示例3: Main

		static void Main()
		{
			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);
			MainForm = new Form1();

			NetPeerConfiguration config = new NetPeerConfiguration("durable");
			config.Port = 14242;
			config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
			config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
			config.EnableUPnP = true;
			Server = new NetServer(config);
			Server.Start();

			// attempt upnp port forwarding
			Server.UPnP.ForwardPort(14242, "Durable sample test");

			m_expectedReliableOrdered = new uint[3];
			m_reliableOrderedCorrect = new int[3];
			m_reliableOrderedErrors = new int[3];

			m_expectedSequenced = new uint[3];
			m_sequencedCorrect = new int[3];
			m_sequencedErrors = new int[3];

			Application.Idle += new EventHandler(AppLoop);
			Application.Run(MainForm);

			Server.Shutdown("App exiting");
		}
开发者ID:pr0gramm3r1,项目名称:AngryTanks,代码行数:30,代码来源:Program.cs

示例4: GameClient

 public GameClient()
 {
     var npcc = new NetPeerConfiguration("SpajsFajt");
     npcc.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
     npcc.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
     netClient = new NetClient(npcc);
     netClient.Start();
 }
开发者ID:elklazor,项目名称:SpajsFajt,代码行数:8,代码来源:GameClient.cs

示例5: WorldPortalConnection

 public WorldPortalConnection()
 {
     CameraPos = new Vector2f(0, 0);
     NetPeerConfiguration config = new NetPeerConfiguration("Dystopia2");
     config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
     config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
     client = new NetClient(config);
     client.Start();
 }
开发者ID:Tricon2-Elf,项目名称:DystopiaRPG,代码行数:9,代码来源:WorldPortalConnection.cs

示例6: GetConfig

        public static NetPeerConfiguration GetConfig()
        {
            NetPeerConfiguration config = new NetPeerConfiguration(AppID);
            config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
            config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
            config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);

            return config;
        }
开发者ID:yegorf1,项目名称:Circles,代码行数:9,代码来源:NetworkGlobals.cs

示例7: GameServer

 public GameServer(int port)
 {
     //Configuration
     var npc = new NetPeerConfiguration("SpajsFajt");
     npc.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
     npc.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
     npc.Port = port;
     netServer = new NetServer(npc);
     netServer.Start();
 }
开发者ID:elklazor,项目名称:SpajsFajt,代码行数:10,代码来源:GameServer.cs

示例8: MasterClient

        public MasterClient()
        {
            m_registeredHosts = new Dictionary<long, Object[]>();

            NetPeerConfiguration config = new NetPeerConfiguration("game");
            config.EnableMessageType(NetIncomingMessageType.UnconnectedData);
            config.EnableMessageType(NetIncomingMessageType.NatIntroductionSuccess);
            m_client = new NetClient(config);
            m_client.Start();
        }
开发者ID:imGoose,项目名称:SkyrimOnline,代码行数:10,代码来源:MasterClient.cs

示例9: Server_Load

        private void Server_Load(object sender, EventArgs e)
        {
            NetPeerConfiguration config = new NetPeerConfiguration("Testing");
            config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
            config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
            config.Port = 50001;

            server =  new NetServer(config);
            server.Start();
        }
开发者ID:DV8FromTheWorld,项目名称:C-Sharp-Programming,代码行数:10,代码来源:Server.cs

示例10: NetManager

        public NetManager()
        {
            _packetHandlers = new Dictionary<PacketType, List<Action<PacketReceivedEventArgs>>>();

            NetPeerConfiguration config = new NetPeerConfiguration("CEngineSharp");
            config.Port = Constants.SERVER_PORT;
            config.EnableMessageType(NetIncomingMessageType.Data);
            config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
            config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);

            _netServer = new NetServer(config);
        }
开发者ID:JohnLamontagne,项目名称:CEngineSharp,代码行数:12,代码来源:NetManager.cs

示例11: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            NetPeerConfiguration config = new NetPeerConfiguration("MMC");
            config.MaximumConnections = 100;
            config.Port = 3939;
            // Enable DiscoveryResponse messages
            config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
            config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);

            s_server = new NetPeer(config);
            Output("listening on " + config.Port.ToString());
            s_server.Start();
        }
开发者ID:jluchiji,项目名称:MMC_Server,代码行数:13,代码来源:Form1.cs

示例12: NetManager

        public NetManager()
        {
            _packetHandlers = new Dictionary<PacketType, List<Action<PacketReceivedEventArgs>>>();
            _packetCache = new List<Tuple<NetOutgoingMessage, NetDeliveryMethod, ChannelTypes>>();

            NetPeerConfiguration config = new NetPeerConfiguration("CEngineSharp");
            config.EnableMessageType(NetIncomingMessageType.Data);
            config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
            config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);

            _netClient = new NetClient(config);
            _netClient.Start();
        }
开发者ID:JohnLamontagne,项目名称:CEngineSharp,代码行数:13,代码来源:NetManager.cs

示例13: Initialize

        public static void Initialize()
        {
            TickRate = Shared.Settings.TickRate;
            if (!System.IO.File.Exists("serverconfig.xml"))
            {
                Console.WriteLine("Config file not found...");
                System.Threading.Thread.Sleep(5000);
                System.Diagnostics.Process.GetCurrentProcess().Kill();
            }
            XmlDocument Config = new XmlDocument();
            Config.Load("serverconfig.xml");
            Port = int.Parse(Config.DocumentElement.SelectSingleNode("/config/serverport").InnerText);
            MaxPlayers = int.Parse(Config.DocumentElement.SelectSingleNode("/config/maxplayers").InnerText);
            XmlNodeList Resources = Config.DocumentElement.SelectNodes("/config/resource");

            NetPeerConfiguration NetConfig = new NetPeerConfiguration("ivmp");
            NetConfig.MaximumConnections = MaxPlayers;
            NetConfig.Port = Port;
            NetConfig.ConnectionTimeout = 50;
            NetConfig.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
            NetConfig.EnableMessageType(NetIncomingMessageType.StatusChanged);
            NetServer = new NetServer(NetConfig);
            NetServer.Start();
            PlayersController = new PlayersController();
            VehiclesController = new VehiclesController();
            ResourcesManager = new Shared.Scripting.ResourcesManager();
            EventsManager = new Shared.Scripting.EventsManager();
            Engine = new Jint.Engine();

            // load resources
            foreach (XmlNode Resource in Resources)
            {
                try
                {
                    ResourcesManager.Load(Resource.Attributes["name"].InnerText);
                    ResourcesManager.Start(Resource.Attributes["name"].InnerText);
                }
                catch(Exception)
                {
                }
            }

            Timer tick = new Timer();
            tick.Elapsed += OnTick;
            tick.Interval = TickRate;
            tick.Enabled = true;
            tick.Start();
            Console.WriteLine("Started game server on Port " + Port);
            Console.WriteLine("Max Players: " + MaxPlayers);
        }
开发者ID:Neproify,项目名称:ivmp,代码行数:50,代码来源:Server.cs

示例14: ServerNetworkInterface

        public ServerNetworkInterface(string appId, 
            int port,
            IServerNetworkManager manager)
        {
            Manager = manager;
            AppId = appId;
            Port = port;
            NetPeerConfiguration config = new NetPeerConfiguration(appId);
            config.Port = port;
            config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
            config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
            config.EnableMessageType(NetIncomingMessageType.UnconnectedData);

            lidgrenServer = new NetServer(config);
        }
开发者ID:bberak,项目名称:PokerDotNet,代码行数:15,代码来源:ServerNetworkInterface.cs

示例15: GetConfiguration

        public static NetPeerConfiguration GetConfiguration(bool server) {
            NetPeerConfiguration config = new NetPeerConfiguration("Forge.Networking");

            if (server) {
                config.Port = Port;
                config.EnableUPnP = true;
                config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
                config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
            }
            else {
                config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
            }

            return config;
        }
开发者ID:jyunfan2015,项目名称:forge,代码行数:15,代码来源:Configuration.cs


注:本文中的Lidgren.Network.NetPeerConfiguration.EnableMessageType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。