JNIEXPORT jlong JNICALL Java_com_phidgets_Dictionary_create(JNIEnv *env, jobject obj) { int error; CPhidgetDictionaryHandle dict; if ((error = CPhidgetDictionary_create(&dict))) PH_THROW(error); return (jlong)(uintptr_t)dict; }
int dictionary_simple() { int result, serverStatus, port; const char *address; result = CPhidgetDictionary_create(&dict); result = CPhidget_set_OnServerConnect_Handler((CPhidgetHandle)dict, ServerConnectedHandler, NULL); result = CPhidget_set_OnServerDisconnect_Handler((CPhidgetHandle)dict, ServerDisconnectedHandler, NULL); result = CPhidgetDictionary_set_OnError_Handler(dict, DictionaryErrorHandler, NULL); result = CPhidgetDictionary_openRemoteIP(dict, "localhost", 5001, NULL); do { result = CPhidgetDictionary_getServerStatus(dict, &serverStatus); }while(serverStatus = PHIDGET_NOTATTACHED); printf("Attached to server\n"); CPhidgetDictionary_getServerAddress(dict, &address, &port); printf("Address: %s -- Port: %i \n", address, port); //Set some keys printf("Add some keys....\n"); sleep(WAITTIME); CPhidgetDictionary_addKey(dict, "TEST1", "234", 1); CPhidgetDictionary_addKey(dict, "TEST2", "5678", 1); CPhidgetDictionary_addKey(dict, "TEST3", "9012", 0); CPhidgetDictionary_addKey(dict, "TEST4", "3456", 1); sleep(WAITTIME); printf("Delete the 4th key....\n"); sleep(WAITTIME); CPhidgetDictionary_removeKey(dict, "TEST4"); sleep(WAITTIME); printf("Press any key to end\n"); getchar(); result = CPhidgetDictionary_close(dict); result = CPhidgetDictionary_delete(dict); return 0; }