|
enum | SL_ErrorReason {
SL_REASON_NONE = 0,
SL_REASON_USER1,
SL_REASON_USER2,
SL_REASON_USER3,
SL_REASON_USER4,
SL_REASON_USER5,
SL_REASON_LICENCE
} |
| Enumeration defining the reasons for an error being raised for a subscription or command. More...
|
|
enum | SL_SubjectType {
SL_SUBJECTTYPE_UNKNOWN = 200,
SL_SUBJECTTYPE_PAGE = 221,
SL_SUBJECTTYPE_RECORD = 222,
SL_SUBJECTTYPE_NEWS = 223,
SL_SUBJECTTYPE_STORY = 224,
SL_SUBJECTTYPE_CHAT = 227,
SL_SUBJECTTYPE_CONTAINER = 228,
SL_SUBJECTTYPE_PERMISSION = 230
} |
| Enumeration that defines the subject types supported by the Liberator. More...
|
|
enum | SL_SubscriptionError {
SL_ERROR_OK = 0,
SL_ERROR_NOTFOUND,
SL_ERROR_UNAVAILABLE,
SL_ERROR_DELETED,
SL_ERROR_READ_DENIED,
SL_ERROR_WRITE_DENIED,
SL_ERROR_INVALID_PARAMETERS,
SL_ERROR_THROTTLE_FAILED,
SL_ERROR_CANCELLED,
SL_ERROR_EXPIRED
} |
| Enumeration defining the errors that can occur for a subscription. More...
|
|
enum | SL_SubjectStatus { SL_STATUS_OK = 0,
SL_STATUS_LIMITED,
SL_STATUS_STALE,
SL_STATUS_INFO
} |
| Enumeration that defines the status of a subject. More...
|
|
StreamLink for iOS operates asynchronously. This means that when your application requests a subscription, the response is not immediately returned, but is supplied later, through a callback that is registered when the subscription was made.
The following example subscribes to the topic /DEMO/MSFT
:
#import <StreamLink/StreamLink.h>
@interface ExampleSubscribeToRecord : NSObject<SLSubscriptionListener> {
}
@end
@implementation ExampleSubscribeToRecord
-(void)subscribeToRecord {
[streamLink connect];
id<SLSubscription> subscription = [streamLink subscribeToSubject:@"/DEMO/MSFT" subscriptionParameters:nil subscriptionListener:self];
NSLog(@"Subscribed to %@", subscription.subject);
}
-(void) recordUpdatedForSubscription:(id<SLSubscription>)subscription data:(id<SLRecordDataEvent>)data {
NSLog(@"recordUpdatedForSubscription: subscription=[%@], data=[%@]", subscription, data);
}
-(void) containerUpdatedForSubscription:(id<SLSubscription>)subscription data:(id<SLContainerDataEvent>)data {
NSLog(@"containerUpdatedForSubscription: subscription=[%@], data=[%@]", subscription, data);
}
-(void) errorForSubscription:(id<SLSubscription>)subscription error:(id<SLSubscriptionErrorEvent>)error {
NSLog(@"errorForSubscription: subscription=[%@], error=[%@]", subscription, error);
}
-(void) statusForSubscription:(id<SLSubscription>)subscription status:(id<SLSubscriptionStatusEvent>)status {
NSLog(@"statusForSubscription: subscription=[%@], status=[%@]", subscription, status);
}
@end
The following example subscribes to a subject that provides JSON data and sets up a JSON handler to handle the updates.
The following header file declares the interface for the JSON handler.
#import <Foundation/Foundation.h>
#import <StreamLink/StreamLink.h>
@interface ExampleJson : NSObject <SLConnectionListener, SLSubscriptionListener,
SLJsonHandler>
{
id<SLStreamLink> streamlink;
id<SLSubscription> subscription;
}
@property (nonatomic, retain) id<SLStreamLink> streamlink;
@property (nonatomic, retain) id<SLSubscription> subscription;
@end
The following example subscribes to the topic /DEMO/JSON
:
#import <StreamLink/StreamLink.h>
#import "ExampleJson.h"
#import <unistd.h>
@implementation ExampleJson
@synthesize streamlink;
@synthesize subscription;
-(void)dealloc
{
[self.subscription unsubscribe];
[self.streamlink disconnect];
[self.subscription release];
[self.streamlink release];
[super dealloc];
}
-(id)init
{
self = [super init];
if (self != nil)
{
config.username = @"admin";
config.password = @"admin";
config.liberatorURLs =@"http://192.168.1.120:18080";
config.jsonHandler= self;
self.streamlink.logger = [[[
SLConsoleLogger alloc] initWithThresholdLevel:SL_LOG_FINEST] autorelease];
self.subscription = [self.streamlink subscribeToSubject:@"/DEMO/JSON" subscriptionParameters:nil subscriptionListener:self];
[self.streamlink addConnectionListener:self];
[self.streamlink connect];
}
return self;
}
-(void) jsonUpdatedForSubscription:(id<SLSubscription>)subscription data:(id<SLJsonDataEvent>)data
{
NSLog(@"Json Updated: %@", data);
}
-(void)connectionStatus:(id<SLConnectionStatusEvent>) connectionStatusEvent
{
NSLog(@"Connection status is now %@", connectionStatusEvent);
}
-(void) serviceStatus:(id<SLConnectionServiceStatusEvent>)serviceStatusEvent
{
NSLog(@"Connection service status for service %@", serviceStatusEvent);
}
-(void) sourceStatus:(id<SLConnectionSourceStatusEvent>) sourceStatusEvent
{
NSLog(@"Connection source status for source %@", sourceStatusEvent);
}
-(NSObject *) parse:(NSString *)jsonString {
NSLog(@"parse %@", jsonString);
return jsonString;
}
-(NSObject *) patch:(NSObject *)existingObject with:(NSString *)jsonPatchString {
NSString *existing = (NSString*)existingObject;
NSString *result = [existing stringByAppendingString: jsonPatchString];
NSLog(@"patch \nexisting: %@ \npatch: %@ \nresult: %@", existing, jsonPatchString, result);
return result;
}
@end
Enumeration defining the reasons for an error being raised for a subscription or command.
Enumerator |
---|
SL_REASON_NONE |
No reason
|
SL_REASON_USER1 |
Liberator auth module user reason
|
SL_REASON_USER2 |
Liberator auth module user reason
|
SL_REASON_USER3 |
Liberator auth module user reason
|
SL_REASON_USER4 |
Liberator auth module user reason
|
SL_REASON_USER5 |
Liberator auth module user reason
|
SL_REASON_LICENCE |
Licence failure
|
Enumeration that defines the status of a subject.
Enumerator |
---|
SL_STATUS_OK |
The data associated with the subject is correct and up-to-date.
|
SL_STATUS_LIMITED |
One of the sources of data for the subject is not available. This may affect the validity of the subject's data.
|
SL_STATUS_STALE |
The subject's data may not be correct and up-to-date.
|
SL_STATUS_INFO |
An informational message about the subject (usually sent by the DataSource)
|
Enumeration that defines the subject types supported by the Liberator.
Enumerator |
---|
SL_SUBJECTTYPE_UNKNOWN |
The subject type is unknown.
|
SL_SUBJECTTYPE_PAGE |
Page data type.
|
SL_SUBJECTTYPE_RECORD |
Record data type.
|
SL_SUBJECTTYPE_NEWS |
News data type.
|
SL_SUBJECTTYPE_STORY |
Story data type
|
SL_SUBJECTTYPE_CHAT |
Chat data type
|
SL_SUBJECTTYPE_CONTAINER |
Container data type.
|
SL_SUBJECTTYPE_PERMISSION |
Permission data type.
|
Enumeration defining the errors that can occur for a subscription.
Enumerator |
---|
SL_ERROR_OK |
No error.
|
SL_ERROR_NOTFOUND |
The subject could not be found.
|
SL_ERROR_UNAVAILABLE |
The subject was not available.
|
SL_ERROR_DELETED |
The subject has been deleted.
|
SL_ERROR_READ_DENIED |
The client does not have permission to read the subject.
|
SL_ERROR_WRITE_DENIED |
The client does not have permission to write to the subject.
|
SL_ERROR_INVALID_PARAMETERS |
The supplied container parameters are invalid
|
SL_ERROR_THROTTLE_FAILED |
Throttle failed
|
SL_ERROR_CANCELLED |
Command has been cancelled
|
SL_ERROR_EXPIRED |
|