本文整理汇总了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!");
}
示例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();
}
示例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();
}
示例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();
}
示例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");
}
示例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();
}
示例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;
}