当然,我们确实有一些事件会在主题添加新消息时通知客户端。使用消息泵机制,您可以使用有效订阅将客户端连接到主题消息。
本质上,下面的代码展示了如何订阅该主题。
static void Main(string[] args)
{
SubscriptionClient Client = null;
OnMessageOptions options;
string connectionString = "your topic Endpoint";
Client =
SubscriptionClient.CreateFromConnectionString
(connectionString, "YourTopicName", "YoursubscriberName");
// Configure the callback options.
options = new OnMessageOptions();
options.AutoComplete = false;
options.AutoRenewTimeout = TimeSpan.FromMinutes(1);
Client.OnMessage((message) =>
{
try
{
Console.WriteLine("Topic Message : ID :" + message.MessageId + " , " + message.Label);
message.Complete();
}
catch (Exception exp)
{
message.Abandon();
Console.WriteLine("**Error Reciving Message**");
}
}, options);
Console.ReadLine();
}
对于推送通知到WP8,看看移动服务。 http://www.windowsazure.com/en-us/documentation/articles/mobile-services-windows-phone-get-started-push/ –
正如我所说的一切工作,即主题/队列创建,发送,接收,删除,发送推送,接收推送。只是我错过了来自主题/队列的事件,如果有新增任何内容。 – masiboo
在c#实现中,您可以使用Client.OnMessage方法来轮询预订消息。 https://msdn.microsoft.com/en-us/library/azure/microsoft.servicebus.messaging.onmessageoptions.aspx。我想在node.js中做到这一点,但似乎我必须手动进行轮询......? – keft