StreamLink for iOS  8.0.0.233163-35883203
SLConnectionListenerWrapper Class Reference

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

Inheritance diagram for SLConnectionListenerWrapper:

Instance Methods

(id) - initWithConnectionListener:
 Creates an instance of an SLConnectionListenerWrapper that wraps the supplied SLConnectionListenerWrapper. More...
 

Class Methods

(SLConnectionListenerWrapper *) + wrapListener:
 Convenience static method that wraps the supplied SLConnectionListener. More...
 

Protected Attributes

id< SLConnectionListener > wrappedListener
 

Detailed Description

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

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

See also
SLSubscriptionListenerWrapper

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

#import <StreamLink/StreamLink.h>
@interface ExampleUsingSLConnectionListenerWrapper : NSObject<SLConnectionListener> {
}
@end
@implementation ExampleUsingSLConnectionListenerWrapper
-(void)connectToServer
{
// Create a streamlink instance that connects to the server "myliberator" with password credentials
id<SLStreamLink> streamLink = [SLStreamLinkFactory createStreamLinkWithConfiguration:@"https://myliberator" username:@"admin" password:@"admin"];
// Register ourselves as a connection listener wrapped in a SLConnectionListenerWrapper
// this will ensure that all connection callbacks will be handled on the main gui thread.
[streamLink addConnectionListener:[SLConnectionListenerWrapper wrapListener:self]];
// Connect to the server
[streamLink connect];
}
// This connection listener callback will be called on the main thread
// so it can directly update the gui.
-(void)connectionStatus:(id<SLConnectionStatusEvent>) connectionStatusEvent
{
NSLog(@"Connection status is now %@", connectionStatusEvent);
}
@end

Method Documentation

- (id) initWithConnectionListener: (id< SLConnectionListener >)  listener

Creates an instance of an SLConnectionListenerWrapper that wraps the supplied SLConnectionListenerWrapper.

Parameters
listenerThe SLConnectionListener to be wrapped. Once wrapped, all callbacks on this listener are on the main GUI thread.
Returns
A new SLConnectionListenerWrapper instance.
+ (SLConnectionListenerWrapper*) wrapListener: (id< SLConnectionListener >)  listener

Convenience static method that wraps the supplied SLConnectionListener.

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

Member Data Documentation

- (id< SLConnectionListener >) wrappedListener
readwritenonatomicretainprotected

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