本文整理汇总了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.");
}
}
}
}
}
示例2: Main
public static void Main()
{
Server server = new Server ();
server.Announce ("mono-test", "test1", "http://www.google.com/");
while (true) {
Thread.Sleep (5000);
}
}
示例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.");
}
}
}
}
}
示例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.");
}
}
}
}
}