#import "EventMonitorExample.h"
@implementation EventMonitorExample
- (id)initWithExampleInterface:(ExampleInterface *)exampleInterface {
self = [super initWithExampleInterface:exampleInterface];
self.name = @"EventMonitor";
self.description = @"Demonstrates how to monitor appliance events using an "
@"event subscription";
[self.parameters addParameter:PARAMETER_NUM_MESSAGES];
return self;
}
messageReceiveCallbackWithSession:
userData:(void *)user_p {
void *binaryAttachmentBuffer_p;
solClient_uint32_t binaryAttachmentBufferSize;
msg_p, &destination,
sizeof(destination))) !=
SOLCLIENT_OK) {
[self handleErrorWithReturnCode:rc
errorString:"solClient_msg_getDestination()"];
}
msg_p, &binaryAttachmentBuffer_p, &binaryAttachmentBufferSize)) !=
[self
handleErrorWithReturnCode:rc
errorString:"solClient_msg_getBinaryAttachmentPtr()"];
}
(char *)binaryAttachmentBuffer_p);
}
if ((rc = [self
createAndConnectSessionWithContext:context_p
session:&session_p
messageCallback:messageReceivePrintMsgCallback
eventCallback:eventCallback]) !=
[self handleErrorWithReturnCode:
rc errorString:"createAndConnectSessionWithContext:session:"
"messageCallback:eventCallback:userData:"];
return rc;
}
[self handleErrorWithReturnCode:rc
errorString:"solClient_session_topicSubscribe()"];
}
[self handleErrorWithReturnCode:rc
errorString:"solClient_session_disconnect()"];
}
return rc;
}
- (void)run {
[super run];
char *eventTopicFormat = "#LOG/INFO/CLIENT/%s/CLIENT_CLIENT_CONNECT/>";
char eventTopic[SOLCLIENT_BUFINFO_MAX_TOPIC_SIZE + 1];
[self handleErrorWithReturnCode:rc
errorString:"solClient_initialize()"];
goto notInitialized;
}
[self setLoggingLevel];
"EventMonitorExample.m (Copyright 2009-2024 Solace Corporation. All rights reserved.)\n");
[self logCCSMPVersion];
&contextFuncInfo,
sizeof(contextFuncInfo))) !=
SOLCLIENT_OK) {
[self handleErrorWithReturnCode:rc
errorString:"solClient_context_create()"];
goto cleanup;
}
if ((rc = [self createAndConnectSessionWithContext:context_p
session:&session_p
messageCallback:messageReceiveCallback
eventCallback:eventCallback]) !=
[self handleErrorWithReturnCode:
rc errorString:"createAndConnectSessionWithContext:session:"
"messageCallback:eventCallback:userData:"];
goto cleanup;
}
[self handleErrorWithReturnCode:rc
errorString:"solClient_session_getCapability()"];
goto sessionConnected;
}
snprintf(eventTopic, sizeof(eventTopic), eventTopicFormat,
[self handleErrorWithReturnCode:rc
errorString:"solClient_session_topicSubscribe()"];
goto sessionConnected;
}
if ((rc = [self triggerSecondaryConnectionWithContext:context_p]) !=
[self handleErrorWithReturnCode:rc
errorString:"triggerSecondaryConnection()"];
goto sessionConnected;
}
[NSThread sleepForTimeInterval:1];
sessionConnected:
[self handleErrorWithReturnCode:rc
errorString:"solClient_session_disconnect()"];
}
cleanup:
[self handleErrorWithReturnCode:rc errorString:"solClient_cleanup()"];
}
notInitialized:
[self cleanup];
}
@end