동기식 스트리밍 알림을 작동 한 후 비동기 BeginSubscribeToStreamingNotifications()
을 발견했습니다.EWS BeginSubscribeToStreamingNotifications 사용
매우 제한된 문서를 사용하여이 작업을 조금만 수행 한 후에는 포기했습니다. 나는 이걸 작동시키지 못한다.
환경
여기에 관련 코드가 있습니다. 서비스를 시작하고 연결하여 BeginSubscribeToStreamingNotifications()
메소드를 호출하고 있습니다.
public static void InitSubscriptions()
{
var service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.Credentials = new NetworkCredential("some", "login", "here");
service.Url = new Uri("https://some.exchange/server");
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "[email protected]");
// Initiating the subscription
var subscription = service.BeginSubscribeToStreamingNotifications(new AsyncCallback(Callback), null, new FolderId[] { WellKnownFolderName.Inbox }, EventType.NewMail);
}
private static void Callback(IAsyncResult result)
{
// ???
}
여러분도 알다시피, 콜백 메소드에서 무엇을해야할지 모르겠습니다.
문제
실제로이 방법을 사용하여 알림을 구독하는 방법을 모르겠어요. 나는 그것을 동 기적으로 작동 시켰지만 가능하다면 비동기 적으로 작동하게하고 싶다.
다음은 의도 한대로 동작하는 동기 예제이다.
public static void InitSubscriptions()
{
var service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.Credentials = new NetworkCredential("some", "login", "here");
service.Url = new Uri("https://some.exchange/server");
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "[email protected]");
// Initiating the subscription
var subscription = service.SubscribeToStreamingNotifications(new FolderId[] { WellKnownFolderName.Inbox }, EventType.NewMail);
var connection = new StreamingSubscriptionConnection(service, 30);
connection.AddSubscription(subscription);
// Delegate handlers
connection.OnNotificationEvent += new StreamingSubscriptionConnection.NotificationEventDelegate(SomeMethod);
connection.OnSubscriptionError += new StreamingSubscriptionConnection.SubscriptionErrorDelegate(SomeErrorMethod);
connection.OnDisconnect += new StreamingSubscriptionConnection.SubscriptionErrorDelegate(SomeDisconnectMethod);
}
내 질문은 : 동 기적으로 스트리밍 구독을 비동기 방식으로 스트리밍 구독으로 변환하려면 어떻게해야합니까?