c – TeamSpeak 3 SDK连接问题
发布时间:2020-12-16 06:51:34 所属栏目:百科 来源:网络整理
导读:我正在尝试将TeamSpeak SDK用于个人项目,但我写的代码给了我奇怪的错误. 我多次阅读文档以查找错误,但我不明白为什么我的程序无法连接到TeamSpeak服务器. 以下是该计划的输出: Client library version: 3.0.3.2 [Build: 1433933257] SDKConnection Status c
我正在尝试将TeamSpeak SDK用于个人项目,但我写的代码给了我奇怪的错误.
我多次阅读文档以查找错误,但我不明白为什么我的程序无法连接到TeamSpeak服务器. 以下是该计划的输出: Client library version: 3.0.3.2 [Build: 1433933257] SDK Connection Status changed to: 1,errorNumber: 0 Connection Status changed to: 0,errorNumber: 1797 failed connection initialization 这是程序代码 #include <iostream> #include <fstream> #include <cstring> #include <teamspeak/clientlib.h> #include <teamspeak/public_errors.h> uint64 connectionHandler; void destroy(); void event_connectStatusChanged(uint64 serverConnectionIDHandler,int newStatus,unsigned int errorNumber); void event_serverError(uint64 serverConnectionHandlerID,const char* errorMessage,unsigned int error,const char* returnCode,const char* extraMessage); int main() { ClientUIFunctions uiFunctions; memset(&uiFunctions,sizeof(struct ClientUIFunctions)); uiFunctions.onConnectStatusChangeEvent = event_connectStatusChanged; uiFunctions.onServerErrorEvent = event_serverError; unsigned int error = ts3client_initClientLib(&uiFunctions,NULL,LogType_FILE,"./"); if (error != ERROR_ok) printf("Error initializing clientlib: %in",error); char* version; error = ts3client_getClientLibVersion(&version); if (error != ERROR_ok) { printf("Error querying clientlib version: %dn",error); return 0; } printf("Client library version: %sn",version); /* Print version */ ts3client_freeMemory(version); /* Release string */ if (ts3client_spawnNewServerConnectionHandler(0,&connectionHandler) != ERROR_ok) { destroy(); return 0; } char* identity; ts3client_createIdentity(&identity); error = ts3client_startConnection(connectionHandler,identity,"127.0.0.1",9987,"test","",""); ts3client_freeMemory(identity); if (error != ERROR_ok) std::cout << "Connection failed!" << std::endl; getchar(); ts3client_stopConnection(connectionHandler,"..."); destroy(); return 0; } void event_connectStatusChanged(uint64 serverConnectionIDHandler,unsigned int errorNumber) { printf("Connection Status changed to: %i,errorNumber: %in",newStatus,errorNumber); if (errorNumber != ERROR_ok) { char* error; ts3client_getErrorMessage(errorNumber,&error); std::cout << error << std::endl; ts3client_freeMemory(error); } } void event_serverError(uint64 serverConnectionHandlerID,const char* extraMessage) { std::cout << "ERROR: " << errorMessage << std::endl << "Extra Message: " << extraMessage << std::endl; } void destroy() { ts3client_destroyServerConnectionHandler(connectionHandler); ts3client_destroyClientLib(); } 解决方法
您的客户端在连接时会立即崩溃.
以下是一些常见的原因: >该地址不存在服务器. 此外,当需要更新客户端,服务器等组件时,可以触发此错误:
参考:https://forum.sinusbot.com/threads/new-connection-status-0-error-1797.2508/ (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |