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


C# NetPeer.RegisterReceivedCallback方法代码示例

本文整理汇总了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();
 }
开发者ID:dvgamer,项目名称:Touno.Sentinel-II,代码行数:12,代码来源:NetworkPeer.cs

示例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();
        }
开发者ID:jluchiji,项目名称:MMC_Server,代码行数:14,代码来源:Form1.cs

示例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;
        }
开发者ID:pklinef,项目名称:open-hardware-monitor,代码行数:19,代码来源:HttpServer.cs


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