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


C# NetPeerConfiguration.DisableMessageType方法代码示例

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


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

示例1: Init

        internal void Init(int port)
        {
            InitMessageHandler();

              int receiveBufferSize = 64;
              int sendBufferSize = 64;
              StringBuilder sb = new StringBuilder(256);
              if (CenterClientApi.GetConfig("ReceiveBufferSize", sb, 256)) {
            receiveBufferSize = int.Parse(sb.ToString());
              }
              if (CenterClientApi.GetConfig("SendBufferSize", sb, 256)) {
            sendBufferSize = int.Parse(sb.ToString());
              }

              m_Config = new NetPeerConfiguration("RoomServer");
              m_Config.MaximumConnections = 1024;
              m_Config.SocketReceiveBufferSize = receiveBufferSize * 1024 * 1024;
              m_Config.SocketSendBufferSize = sendBufferSize * 1024 * 1024;
              m_Config.Port = port;
              m_Config.DisableMessageType(NetIncomingMessageType.DebugMessage);
              m_Config.DisableMessageType(NetIncomingMessageType.VerboseDebugMessage);
              //m_Config.EnableMessageType(NetIncomingMessageType.DebugMessage);
              //m_Config.EnableMessageType(NetIncomingMessageType.VerboseDebugMessage);
              m_Config.EnableMessageType(NetIncomingMessageType.ErrorMessage);
              m_Config.EnableMessageType(NetIncomingMessageType.WarningMessage);

              if (m_Config.IsMessageTypeEnabled(NetIncomingMessageType.DebugMessage))
            LogSys.Log(LOG_TYPE.DEBUG, "Enable NetIncomingMessageType.DebugMessage");
              if (m_Config.IsMessageTypeEnabled(NetIncomingMessageType.VerboseDebugMessage))
            LogSys.Log(LOG_TYPE.DEBUG, "Enable NetIncomingMessageType.VerboseDebugMessage");
              if (m_Config.IsMessageTypeEnabled(NetIncomingMessageType.ErrorMessage))
            LogSys.Log(LOG_TYPE.DEBUG, "Enable NetIncomingMessageType.ErrorMessage");
              if (m_Config.IsMessageTypeEnabled(NetIncomingMessageType.WarningMessage))
            LogSys.Log(LOG_TYPE.DEBUG, "Enable NetIncomingMessageType.WarningMessage");

              m_NetServer = new NetServer(m_Config);
              m_NetServer.Start();
              m_IOThread = new Thread(new ThreadStart(IOHandler));
              m_IOThread.Name = "IOHandler";
              m_IOThread.IsBackground = true;
              m_Status = RoomSrvStatus.STATUS_RUNNING;
              m_IOThread.Start();
              RoomPeerMgr.Instance.Init();
              Console.WriteLine("Init IOManager OK!");
        }
开发者ID:dreamanlan,项目名称:CSharpGameFramework,代码行数:45,代码来源:IoManager.cs

示例2: ClientSocketManager

        /// <summary>
        /// Initializes a new instance of the <see cref="ClientSocketManager"/> class.
        /// </summary>
        /// <param name="appIdentifier">The application identifier string.</param>
        public ClientSocketManager(string appIdentifier)
        {
            var config = new NetPeerConfiguration(appIdentifier) { AcceptIncomingConnections = false };

            // Disable some message types that will not be used by the client
            config.DisableMessageType(NetIncomingMessageType.NatIntroductionSuccess);
            config.DisableMessageType(NetIncomingMessageType.Receipt);
            config.DisableMessageType(NetIncomingMessageType.UnconnectedData);
            config.DisableMessageType(NetIncomingMessageType.DiscoveryRequest);
            config.DisableMessageType(NetIncomingMessageType.DiscoveryResponse);

            // Custom configuration
            InitNetPeerConfig(config);

            // Start
            _local = new NetClient(config);
            _local.Start();
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:22,代码来源:ClientSocketManager.cs

示例3: ServerSocketManager

        /// <summary>
        /// Initializes a new instance of the <see cref="ServerSocketManager"/> class.
        /// </summary>
        /// <param name="appIdentifier">The application identifier string.</param>
        /// <param name="port">The port to listen on.</param>
        public ServerSocketManager(string appIdentifier, int port)
        {
            var config = new NetPeerConfiguration(appIdentifier)
            { AcceptIncomingConnections = true, Port = port, MaximumConnections = 50 };

            // Disable some message types that will not be used by the server
            config.DisableMessageType(NetIncomingMessageType.NatIntroductionSuccess);
            config.DisableMessageType(NetIncomingMessageType.Receipt);
            config.DisableMessageType(NetIncomingMessageType.UnconnectedData);
            config.DisableMessageType(NetIncomingMessageType.DiscoveryRequest);
            config.DisableMessageType(NetIncomingMessageType.DiscoveryResponse);

            // Manually handle connection approval instead of just accepting everything
            config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);

            // Custom configuration
            InitNetPeerConfig(config);

            // Start
            _local = new NetServer(config);
            _local.Start();
        }
开发者ID:Furt,项目名称:netgore,代码行数:27,代码来源:ServerSocketManager.cs

示例4: NetServiceImpl

 public NetServiceImpl()
 {
     JObject constants = JObject.Parse(File.ReadAllText("Content/Json/config.json"));
     tag = constants.Value<String>("tag");
     port = constants.Value<int>("port");
     clientport = constants.Value<int>("clientport");
     discoveryWait = constants.Value<int>("discoverywait");
     config = new NetPeerConfiguration(tag);
     config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
     config.DisableMessageType(NetIncomingMessageType.DiscoveryRequest);
     //config.Port = clientport;
     client = new NetClient(config);
     client.Start();
 }
开发者ID:Will2817,项目名称:COMP3004,代码行数:14,代码来源:NetServiceImpl.cs

示例5: MineWorldServer

 public MineWorldServer()
 {
     NetPeerConfiguration netConfig = new NetPeerConfiguration("MineWorld");
     netConfig.Port = Constants.MineworldPort;
     netConfig.MaximumConnections = 2;
     netConfig.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
     netConfig.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
     netConfig.DisableMessageType(NetIncomingMessageType.UnconnectedData);
     Server = new NetServer(netConfig);
     GameWorld = new GameWorld(this);
     Console = new MineWorldConsole(this);
     ServerListener = new ServerListener(Server,this);
     ServerSender = new ServerSender(Server, this);
     Listener = new Thread(ServerListener.Start);
     MapManager = new MapManager();
     PlayerManager = new PlayerManager();
     Configloader = new ConfigFile("Data/Settings.ini");
 }
开发者ID:dkfdevil,项目名称:Mine-World,代码行数:18,代码来源:MineWorldServer.cs

示例6: Initialize

        public void Initialize(IServerConfiguration configuration)
        {
            var netPeerConfiguration = new NetPeerConfiguration("LidgrenConfig");
            netPeerConfiguration.Port = configuration.Port;
            netPeerConfiguration.DisableMessageType(NetIncomingMessageType.UnconnectedData);
            netPeerConfiguration.DisableMessageType(NetIncomingMessageType.DiscoveryRequest);
            netPeerConfiguration.DisableMessageType(NetIncomingMessageType.DiscoveryResponse);

            server = new NetServer(netPeerConfiguration);

            Reader = new LidgrenMessageReader(server);
            Writer = new LidgrenMessageWriter(server);

            connections.Clear();
        }
开发者ID:JohanGl,项目名称:Outworld-XNA,代码行数:15,代码来源:LidgrenServer.cs

示例7: GetStandardConfiguration

 public static NetPeerConfiguration GetStandardConfiguration(this NetPeerConfiguration self)
 {
     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.AcceptIncomingConnections = true;
     // No need to assign a port, as the OS will automatically assign an available port
     return config;
 }
开发者ID:theslyone,项目名称:RemoteDesktop,代码行数:29,代码来源:NetPeerConfigurationExtensions.cs


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