本文整理汇总了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;
}
示例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 );
}
}
}
示例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");
}
示例4: GameClient
public GameClient()
{
var npcc = new NetPeerConfiguration("SpajsFajt");
npcc.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
npcc.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
netClient = new NetClient(npcc);
netClient.Start();
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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;
}