|
Code Sample: using the SI Conversation Factory |
| Description |
Here is an example of how to use the SI Conversation
Factory.
| Commented code |
CaiErr cai_err = CAI_OK; CAI_Conversation *conversation = NULL; CAI_FlatConversation flat_conversation; CAI_Dump API_Dump; CAI_Connection_SI connection; CAI_Authentication authentication; CAI_OpenType open_type; CAI_CustomSign customsign; CAI_ConversationFactory *factory = NULL; CAI_XML_BUFFER reply; CAI_Version version; CAI_ConversationInfo conversation_info; char iniFile = (char*)"v2.ini" /* Initialization part */ CAI_initCustomSign(&customsign); CAI_initConnection_SI(&connection); CAI_initAuthentication(&authentication); CAI_initOpenType(&open_type); /*initialize the connection parameters*/ cai_err = CAI_getConnectionInfoFromINI(iniFile,&connection); /*initialize the authentication parameters*/ authentication.corporate_id = (unsigned char *) "guest"; authentication.user_id = (unsigned char *) "guest"; authentication.password = (unsigned char *) "guest"; /*initialize the custom sign-in parameters*/ cai_err = cai_err = CAI_getCustomSignInfoFromINI(iniFile,"Office1",&customsign); /* Note: fill custom_sign parameters here for changePOS feature */ /*initialize the open_type parameters*/ open_type.bind_host_resource=0; /* Fast Open */ open_type.custom_sign = &customsign; /* Create the factory, open conversation, ... */ printf("Creating the conversation Factory ...\n"); cai_err = CAI_createConversationFactory_SI(&connection, &authentication, &factory); check_APIv2Err(cai_err, "createConversationFactory", NULL, &factory); printf("*****************************************************\n"); printf("Opening a conversation from the Factory ...\n"); cai_err = CAI_openConversationFromFactory(factory, &open_type, &conversation); check_APIv2Err(cai_err, "openConversationFromFactory", &conversation, &factory); printf("*****************************************************\n"); printf("Serializing the conversation from the Factory ...\n"); CAI_initFlatConversation(&flat_conversation); cai_err = CAI_serializeConversationFromFactory(factory, &conversation, &flat_conversation); check_APIv2Err(cai_err, "serializeConversation", &conversation, &factory); printf("*****************************************************\n"); printf("Unserializing the conversation from the Factory ...\n"); cai_err = CAI_unserializeConversationFromFactory(factory, &flat_conversation, &conversation); check_APIv2Err(cai_err, "unserializeConversation", &conversation, &factory); printf("*****************************************************\n"); CAI_releaseFlatConversation(&flat_conversation); printf("Closing the conversation from the Factory ...\n"); cai_err = CAI_closeConversationFromFactory(factory, &conversation); check_APIv2Err(cai_err, "closeConversationFromFactory", NULL, &factory); printf("*****************************************************\n"); CAI_releaseConversationFactory(&factory); |
Also see SI migration page.