#import "SubscribeOnBehalfOfClientExample.h"
@implementation SubscribeOnBehalfOfClientExample
- (id)initWithExampleInterface:(ExampleInterface *)exampleInterface {
self = [super initWithExampleInterface:exampleInterface];
self.name = @"SubscribeOnBehalfOfClient";
self.description =
@"Demonstrates how to subscribe on behalf of another client";
return self;
}
- (void)run {
[super run];
const char *topic_str = "sample/topic/pasta";
static const char subscriptionManager[] = "Subscription Manager";
static const char subscriptionClient[] = "Subscription Client";
char clientName_a[SOLCLIENT_SESSION_PROP_MAX_CLIENT_NAME_LEN + 1];
const char *props[40];
int propIndex;
[self handleErrorWithReturnCode:rc
errorString:"solClient_initialize()"];
goto notInitialized;
}
[self setLoggingLevel];
"SubscribeOnBehalfOfClientExample.m (Copyright 2010-2024 Solace Corporation. All rights reserved. "
"Systems, Inc. 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:&sessionMgr_p
messageCallback:messageReceivePrintMsgCallback
eventCallback:eventCallback]) !=
[self handleErrorWithReturnCode:
rc errorString:"createAndConnectSessionWithContext:session:"
"messageCallback:eventCallback:userData:"];
goto cleanup;
}
if ((rc = [self
createAndConnectSessionWithContext:context_p
session:&sessionClient_p
messageCallback:messageReceivePrintMsgCallback
eventCallback:eventCallback]) !=
[self handleErrorWithReturnCode:
rc errorString:"createAndConnectSessionWithContext:session:"
"messageCallback:eventCallback:userData:"];
goto cleanup;
}
"Subscription Manager Not Supported. Exiting");
goto sessionConnected;
} else {
}
[self handleErrorWithReturnCode:rc
errorString:"solClient_session_getProperty()"];
goto sessionConnected;
}
"Adding subscription %s in %s on behalf of client %s",
topic_str, subscriptionManager, subscriptionClient);
propIndex = 0;
props[propIndex++] = clientName_a;
props[propIndex++] = NULL;
(char **)props, sessionMgr_p,
[self handleErrorWithReturnCode:
rc errorString:"solClient_session_endpointTopicSubscribe()"];
goto sessionConnected;
}
if ([self publishMessageWithSession:sessionMgr_p
topic:(char *)topic_str
[self handleErrorWithReturnCode:rc
errorString:"common_publishDirectMessage()"];
goto sessionConnected;
}
[NSThread sleepForTimeInterval:0.5];
sessionConnected:
[self handleErrorWithReturnCode:rc
errorString:"solClient_session_disconnect()"];
}
[self handleErrorWithReturnCode:rc
errorString:"solClient_session_disconnect()"];
}
cleanup:
[self handleErrorWithReturnCode:rc errorString:"solClient_cleanup()"];
}
notInitialized:
[self cleanup];
}
@end