本文整理汇总了C#中Lidgren.Network.NetPeer.RegisterReceivedCallback方法的典型用法代码示例。如果您正苦于以下问题:C# NetPeer.RegisterReceivedCallback方法的具体用法?C# NetPeer.RegisterReceivedCallback怎么用?C# NetPeer.RegisterReceivedCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lidgren.Network.NetPeer
的用法示例。
在下文中一共展示了NetPeer.RegisterReceivedCallback方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NetworkPeer
/// <summary>
/// Creates and starts a new NetworkPeer object, for servers.
/// </summary>
/// <param name="port">The port the server should listen on.</param>
/// <param name="protocols">An array of messaging protocols.</param>
public NetworkPeer(int port, params Protocol[] protocols)
{
Protocols = new List<Protocol>(protocols);
netPeer = new NetPeer(new NetPeerConfiguration("N/A").GetStandardConfiguration(port));
netPeer.RegisterReceivedCallback(OnMessageReceivedCallback);
Start();
}
示例2: button1_Click
private void button1_Click(object sender, EventArgs e)
{
NetPeerConfiguration config = new NetPeerConfiguration("MMC");
config.MaximumConnections = 100;
config.Port = 39393;
// Enable DiscoveryResponse messages
config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
s_server = new NetPeer(config);
Output("listening on " + config.Port.ToString());
s_server.RegisterReceivedCallback(new SendOrPostCallback(GotMessage));
s_server.Start();
}
示例3: HttpServer
public HttpServer(Node r, int p)
{
root = r;
listenerHttpPort = p;
//JSON node count.
nodeCount = 0;
listener = new HttpListener();
NetPeerConfiguration config = new NetPeerConfiguration("OpenHardwareMonitor");
config.Port = p + 1;
config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
peer = new NetPeer(config);
peer.RegisterReceivedCallback(new SendOrPostCallback(HandlePeerMessages));
peerTimer = new System.Timers.Timer();
peerTimer.Elapsed += new ElapsedEventHandler(TimerElapsed);
peerTimer.Interval = 1000 * 60 * 1;
}