[EWS]如何: 通过使用 Exchange 中的 EWS 流有关邮箱事件的通知
发布时间:2020-12-15 04:37:41 所属栏目:百科 来源:网络整理
导读:在之前的文章中,介绍ews拉通知的模式订阅邮件。详情可阅读这篇文章:?,可以看到拉通知的模式,是一次订阅,然后定时器不停的请求服务器。 流通知 流式处理通知依赖悬挂 get 请求在服务器上保留流订阅连接以便连接处于活动状态时所发生的任何事件传送到客户
在之前的文章中,介绍ews拉通知的模式订阅邮件。详情可阅读这篇文章:?,可以看到拉通知的模式,是一次订阅,然后定时器不停的请求服务器。 流通知流式处理通知依赖悬挂 get 请求在服务器上保留流订阅连接以便连接处于活动状态时所发生的任何事件传送到客户端立即打开。过程中的一个连接,并连接保持打开直到间隔过期,或最多 30 分钟可以发送多个通知。连接到期后,客户端发送悬挂再次 get 请求。图 2 显示了流订阅和流式处理通知的工作方式。 c#代码
StreamingSubscription =<span style="color: #008000;">//<span style="color: #008000;"> Create a streaming connection to the service object,over which events are returned to the client.
<span style="color: #008000;">//<span style="color: #008000;"> Keep the streaming connection open for 30 minutes. StreamingSubscriptionConnection connection = <span style="color: #0000ff;">new StreamingSubscriptionConnection(service,<span style="color: #800080;">30<span style="color: #000000;">); connection.AddSubscription(StreamingSubscription); connection.OnNotificationEvent +=<span style="color: #000000;"> OnNotificationEvent; connection.OnDisconnect +=<span style="color: #000000;"> OnDisconnect; connection.Open(); 可以通过上面代码看到,可以流通知方式,可以保持长连接,监听30分钟内收件箱邮件的事件,如果超时,可以出发断开连接的事件。这时我们可以再次创建连接。 获取邮件内容 OnNotificationEvent( (args != (NotificationEvent notificationEvent (notificationEvent == Item.Bind(
}
}
}</span></pre>
参考文章流通知 https://msdn.microsoft.com/zh-cn/library/office/dn458792(v=exchg.150).aspx 三种通知模式 https://msdn.microsoft.com/zh-cn/library/office/dn458791(v=exchg.150).aspx (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |