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


C# Server.Announce方法代码示例

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


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

示例1: AnnouncementTest

 public void AnnouncementTest ()
 {
     using (var socket = CreateSocket ()) {
         using (var server = new Server ()) {
             socket.Bind (ip_endpoint);
             var buffer = new byte[1024];
             socket.BeginReceiveFrom (buffer, 0, buffer.Length, SocketFlags.None, ref endpoint,
                 result => {
                     lock (mutex) {
                         socket.EndReceiveFrom (result, ref endpoint);
                         var datagram = Encoding.ASCII.GetString (buffer, 0, buffer.Length);
                         Assert.IsTrue (datagram.StartsWith ("NOTIFY * HTTP/1.1\r\n"));
                         Monitor.Pulse (mutex);
                     }
                 }, null
             );
             lock (mutex) {
                 server.Announce ("test-service", "test1", "http://localhost/");
                 if (!Monitor.Wait (mutex, TimeSpan.FromSeconds (5))) {
                     Assert.Fail ("The server notification timed out.");
                 }
             }
         }
     }
 }
开发者ID:rsweeney21,项目名称:Mono.Upnp,代码行数:25,代码来源:ServerTests.cs

示例2: Main

 public static void Main()
 {
     Server server = new Server ();
     server.Announce ("mono-test", "test1", "http://www.google.com/");
     while (true) {
         Thread.Sleep (5000);
     }
 }
开发者ID:MustafaUzumcuCom,项目名称:mono-upnp,代码行数:8,代码来源:ConsoleServer.cs

示例3: BrowseAllSearchTest

 public void BrowseAllSearchTest ()
 {
     using (var client = new Client ()) {
         using (var server = new Server ()) {
             server.Announce ("upnp:test", "uuid:mono-upnp-tests:test", "http://localhost/");
             client.ServiceAdded += ClientServiceAdded;
             lock (mutex) {
                 client.BrowseAll ();
                 if (!Monitor.Wait (mutex, TimeSpan.FromSeconds (30))) {
                     Assert.Fail ("The announcement timed out.");
                 }
             }
         }
     }
 }
开发者ID:pacificIT,项目名称:mono-upnp,代码行数:15,代码来源:ClientTests.cs

示例4: BrowseAnnouncementExclusionTest

 public void BrowseAnnouncementExclusionTest ()
 {
     using (var client = new Client ()) {
         using (var server = new Server ()) {
             client.ServiceAdded += (sender, args) => {
                 lock (mutex) {
                     if (args.Service.ServiceType != "upnp:test") {
                         Monitor.Pulse (mutex);
                     }
                 }
             };
             client.Browse ("upnp:test");
             lock (mutex) {
                 server.Announce ("upnp:test:fail", "uuid:mono-upnp-tests:test1", "http://localhost/");
                 server.Announce ("upnp", "uuid:mono-upnp-tests:test2", "http://localhost/");
                 server.Announce ("upnp:test", "uuid:mono-upnp-tests:test3", "http://localhost/");
                 if (Monitor.Wait (mutex, TimeSpan.FromSeconds (30))) {
                     Assert.Fail ("The client recieved invalid announcements.");
                 }
             }
         }
     }
 }
开发者ID:pacificIT,项目名称:mono-upnp,代码行数:23,代码来源:ClientTests.cs


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