StreamLink for iOS  8.0.0.233163-35883203
SLSubscriptionListenerWrapper Class Reference

Defines a subscription listener that wraps an SLSubscriptionListener so that the callbacks are returned on the main GUI thread. More...

Inheritance diagram for SLSubscriptionListenerWrapper:

Instance Methods

(id) - initWithSubscriptionListener:
 Creates an instance of SLSubscriptionListenerWrapper that wraps the supplied SLSubscriptionListener. More...
 

Class Methods

(SLSubscriptionListenerWrapper *) + wrapListener:
 Convenience static method that wraps the supplied SLSubscriptionListener. More...
 

Protected Attributes

id< SLSubscriptionListener > wrappedListener
 

Detailed Description

Defines a subscription listener that wraps an SLSubscriptionListener so that the callbacks are returned on the main GUI thread.

You can pass an SLSubscriptionListenerWrapper to [SLStreamLink subscribe] in place of an SLSubscriptionListener. This allows you to update the GUI from within the wrapped SLSubscriptionListener's callback methods, without having to write boiler-plate code for accessing the GUI thread.

See also
SLConnectionListenerWrapper

The following example shows how to create and use an SLSubscriptionListenerWrapper:

#import <StreamLink/StreamLink.h>
@interface ExampleUsingSLSubscriptionListenerWrapper : NSObject<SLSubscriptionListener> {
}
@end
@implementation ExampleUsingSLSubscriptionListenerWrapper
/* NOTE: For reasons of clarity this example does not implement the SLSubscriptionListener protocol */
-(void)subscribeToRecord
{
// Create a streamlink instance that connects to the server "myliberator" with password credentials
id<SLStreamLink> streamLink = [SLStreamLinkFactory createStreamLinkWithConfiguration:@"https://myliberator" username:@"admin" password:@"admin"];
// Connect to the server
[streamLink connect];
// Create an SLSubscriptionListenerWrapper which will ensure that all callbacks will be handled on the
// main gui thread.
id<SLSubscriptionListener> listener = [SLSubscriptionListenerWrapper wrapListener:self];
// Subscribe to the subject /DEMO/MSFT with no parameters, with callbacks coming into this object on the
// main gui thread.
id<SLSubscription> subscription = [streamLink subscribeToSubject:@"/DEMO/MSFT" subscriptionParameters:nil subscriptionListener:listener];
}
@end

Method Documentation

- (id) initWithSubscriptionListener: (id< SLSubscriptionListener >)  listener

Creates an instance of SLSubscriptionListenerWrapper that wraps the supplied SLSubscriptionListener.

Parameters
listenerThe SLSubscriptionListener to be wrapped. Once wrapped, all callbacks on this listener are on the main GUI thread.
+ (SLSubscriptionListenerWrapper*) wrapListener: (id< SLSubscriptionListener >)  listener

Convenience static method that wraps the supplied SLSubscriptionListener.

Parameters
listenerThe SLSubscriptionListener to be wrapped. Once wrapped, all callbacks on this listener are on the main GUI thread.
Returns
A new SLSubscriptionListenerWrapper instance.

Member Data Documentation

- (id< SLSubscriptionListener >) wrappedListener
readwritenonatomicretainprotected

Generated on Tue Apr 23 2024 11:14:03 for StreamLink for iOS