Class StreamingSubscriptionConnection
- java.lang.Object
-
- microsoft.exchange.webservices.data.notification.StreamingSubscriptionConnection
-
- All Implemented Interfaces:
Closeable,AutoCloseable,HangingServiceRequestBase.IHandleResponseObject,HangingServiceRequestBase.IHangingRequestDisconnectHandler
public final class StreamingSubscriptionConnection extends Object implements Closeable, HangingServiceRequestBase.IHandleResponseObject, HangingServiceRequestBase.IHangingRequestDisconnectHandler
Represents a connection to an ongoing stream of events.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceStreamingSubscriptionConnection.INotificationEventDelegatestatic interfaceStreamingSubscriptionConnection.ISubscriptionErrorDelegate
-
Constructor Summary
Constructors Constructor Description StreamingSubscriptionConnection(ExchangeService service, int lifetime)Initializes a new instance of the StreamingSubscriptionConnection class.StreamingSubscriptionConnection(ExchangeService service, Iterable<StreamingSubscription> subscriptions, int lifetime)Initializes a new instance of the StreamingSubscriptionConnection class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddOnDisconnect(StreamingSubscriptionConnection.ISubscriptionErrorDelegate disconnect)Set event to happen when property disconnect.voidaddOnNotificationEvent(StreamingSubscriptionConnection.INotificationEventDelegate notificationEvent)Set event to happen when property Notify.voidaddOnSubscriptionError(StreamingSubscriptionConnection.ISubscriptionErrorDelegate subscriptionError)Set event to happen when property subscriptionError.voidaddSubscription(StreamingSubscription subscription)Adds a subscription to this connection.voidclearDisconnect()Clears disconnect events list.voidclearNotificationEvent()Clears notification events list.voidclearSubscriptionError()Clears subscription events list.voidclose()Closes this connection so it stops receiving events from the server.This terminates a long-standing call to EWS.voiddispose()Frees resources associated with this StreamingSubscriptionConnection.booleangetIsOpen()Gets a value indicating whether this connection is openedvoidhandleResponseObject(Object response)Callback delegate to handle asynchronous response.voidhangingRequestDisconnectHandler(Object sender, HangingRequestDisconnectEventArgs args)Delegate method to handle a hanging request disconnection.voidopen()Opens this connection so it starts receiving events from the server.This results in a long-standing call to EWS.voidremoveDisconnect(StreamingSubscriptionConnection.ISubscriptionErrorDelegate disconnect)Remove the event from happening when property disconnect.voidremoveNotificationEvent(StreamingSubscriptionConnection.INotificationEventDelegate notificationEvent)Remove the event from happening when property Notify.voidremoveSubscription(StreamingSubscription subscription)Removes the specified streaming subscription from the connection.voidremoveSubscriptionError(StreamingSubscriptionConnection.ISubscriptionErrorDelegate subscriptionError)Remove the event from happening when property subscription.
-
-
-
Constructor Detail
-
StreamingSubscriptionConnection
public StreamingSubscriptionConnection(ExchangeService service, int lifetime) throws Exception
Initializes a new instance of the StreamingSubscriptionConnection class.- Parameters:
service- The ExchangeService instance this connection uses to connect to the server.lifetime- The maximum time, in minutes, the connection will remain open. Lifetime must be between 1 and 30.- Throws:
Exception
-
StreamingSubscriptionConnection
public StreamingSubscriptionConnection(ExchangeService service, Iterable<StreamingSubscription> subscriptions, int lifetime) throws Exception
Initializes a new instance of the StreamingSubscriptionConnection class.- Parameters:
service- The ExchangeService instance this connection uses to connect to the server.subscriptions- Iterable subcriptionslifetime- The maximum time, in minutes, the connection will remain open. Lifetime must be between 1 and 30.- Throws:
Exception
-
-
Method Detail
-
addOnNotificationEvent
public void addOnNotificationEvent(StreamingSubscriptionConnection.INotificationEventDelegate notificationEvent)
Set event to happen when property Notify.- Parameters:
notificationEvent- notification event
-
removeNotificationEvent
public void removeNotificationEvent(StreamingSubscriptionConnection.INotificationEventDelegate notificationEvent)
Remove the event from happening when property Notify.- Parameters:
notificationEvent- notification event
-
clearNotificationEvent
public void clearNotificationEvent()
Clears notification events list.
-
addOnSubscriptionError
public void addOnSubscriptionError(StreamingSubscriptionConnection.ISubscriptionErrorDelegate subscriptionError)
Set event to happen when property subscriptionError.- Parameters:
subscriptionError- subscription event
-
removeSubscriptionError
public void removeSubscriptionError(StreamingSubscriptionConnection.ISubscriptionErrorDelegate subscriptionError)
Remove the event from happening when property subscription.- Parameters:
subscriptionError- subscription event
-
clearSubscriptionError
public void clearSubscriptionError()
Clears subscription events list.
-
addOnDisconnect
public void addOnDisconnect(StreamingSubscriptionConnection.ISubscriptionErrorDelegate disconnect)
Set event to happen when property disconnect.- Parameters:
disconnect- disconnect event
-
removeDisconnect
public void removeDisconnect(StreamingSubscriptionConnection.ISubscriptionErrorDelegate disconnect)
Remove the event from happening when property disconnect.- Parameters:
disconnect- disconnect event
-
clearDisconnect
public void clearDisconnect()
Clears disconnect events list.
-
addSubscription
public void addSubscription(StreamingSubscription subscription) throws Exception
Adds a subscription to this connection.- Parameters:
subscription- The subscription to add.- Throws:
Exception- Thrown when AddSubscription is called while connected.
-
removeSubscription
public void removeSubscription(StreamingSubscription subscription) throws Exception
Removes the specified streaming subscription from the connection.- Parameters:
subscription- The subscription to remove.- Throws:
Exception- Thrown when RemoveSubscription is called while connected.
-
open
public void open() throws ServiceLocalException, Exception
Opens this connection so it starts receiving events from the server.This results in a long-standing call to EWS.- Throws:
ExceptionServiceLocalException- Thrown when Open is called while connected.
-
close
public void close()
Closes this connection so it stops receiving events from the server.This terminates a long-standing call to EWS.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getIsOpen
public boolean getIsOpen() throws Exception
Gets a value indicating whether this connection is opened- Throws:
Exception
-
dispose
public void dispose()
Frees resources associated with this StreamingSubscriptionConnection.
-
handleResponseObject
public void handleResponseObject(Object response) throws ArgumentException
Description copied from interface:HangingServiceRequestBase.IHandleResponseObjectCallback delegate to handle asynchronous response.- Specified by:
handleResponseObjectin interfaceHangingServiceRequestBase.IHandleResponseObject- Parameters:
response- Response received from the server- Throws:
ArgumentException
-
hangingRequestDisconnectHandler
public void hangingRequestDisconnectHandler(Object sender, HangingRequestDisconnectEventArgs args)
Description copied from interface:HangingServiceRequestBase.IHangingRequestDisconnectHandlerDelegate method to handle a hanging request disconnection.- Specified by:
hangingRequestDisconnectHandlerin interfaceHangingServiceRequestBase.IHangingRequestDisconnectHandler- Parameters:
sender- the object invoking the delegateargs- event data
-
-