if(init && start && end && sl) init("Agent007", "PremiumSupport"); start("INT-001"); Sleep(2000); end("INT-001", 0); printf("Service Level: %.1f%%\n", sl("PremiumSupport"));
auto init = (COPCDLL_API int(__stdcall*)(const char*, const char*))GetProcAddress(dll, "CopcInit"); auto start = (COPCDLL_API int(__stdcall*)(const char*))GetProcAddress(dll, "CopcLogStart"); auto end = (COPCDLL_API int(__stdcall*)(const char*, int))GetProcAddress(dll, "CopcLogEnd"); auto sl = (COPCDLL_API double(__stdcall*)(const char*))GetProcAddress(dll, "CopcGetServiceLevel");
// Log an interaction start (call, chat, etc.) COPCDLL_API int __stdcall CopcLogStart(const char* interactionId);
cl /LD /DBUILDING_COPC_DLL copc_dll.c /FeCOPC.dll
// Cleanup resources COPCDLL_API void __stdcall CopcShutdown(void);
int __stdcall CopcLogStart(const char* interactionId) activeCount >= 256) return -1; InteractionRecord* rec = &activeInteractions[activeCount++]; strncpy(rec->interactionId, interactionId, sizeof(rec->interactionId)-1); rec->startTime = time(NULL); rec->abandoned = 0; logEvent("Interaction start logged"); return 0;
int __stdcall CopcLogEnd(const char* interactionId, int abandoned) for (int i = 0; i < activeCount; i++) if (strcmp(activeInteractions[i].interactionId, interactionId) == 0) time_t now = time(NULL); double handleTime = difftime(now, activeInteractions[i].startTime); // In real COPC: update handle time, service level stats char buf[256]; sprintf(buf, "End %s, abandoned=%d, handle=%.2f sec", interactionId, abandoned, handleTime); logEvent(buf); // remove by swapping with last activeInteractions[i] = activeInteractions[--activeCount]; return 0;
// Dummy internal logging static void logEvent(const char* msg) char buf[512]; SYSTEMTIME st; GetLocalTime(&st); sprintf(buf, "[%02d:%02d:%02d] COPC: %s\n", st.wHour, st.wMinute, st.wSecond, msg); OutputDebugStringA(buf); // logs to debug output / can write to file
void __stdcall CopcShutdown(void) logEvent("CopcShutdown"); activeCount = 0;