本文整理汇总了C++中CJabberProto::FileSendParse方法的典型用法代码示例。如果您正苦于以下问题:C++ CJabberProto::FileSendParse方法的具体用法?C++ CJabberProto::FileSendParse怎么用?C++ CJabberProto::FileSendParse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CJabberProto
的用法示例。
在下文中一共展示了CJabberProto::FileSendParse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: JabberFileServerConnection
void JabberFileServerConnection(JABBER_SOCKET hConnection, DWORD /*dwRemoteIP*/, void* extra)
{
CJabberProto *ppro = (CJabberProto*)extra;
NETLIBCONNINFO connInfo = { sizeof(connInfo) };
CallService(MS_NETLIB_GETCONNECTIONINFO, (WPARAM)hConnection, (LPARAM)&connInfo);
TCHAR szPort[10];
mir_sntprintf(szPort, _countof(szPort), _T("%d"), connInfo.wPort);
ppro->debugLogA("File server incoming connection accepted: %s", connInfo.szIpPort);
JABBER_LIST_ITEM *item = ppro->ListGetItemPtr(LIST_FILE, szPort);
if (item == NULL) {
ppro->debugLogA("No file is currently served, file server connection closed.");
Netlib_CloseHandle(hConnection);
return;
}
filetransfer *ft = item->ft;
JABBER_SOCKET slisten = ft->s;
ft->s = hConnection;
ppro->debugLogA("Set ft->s to %d (saving %d)", hConnection, slisten);
char* buffer = (char*)mir_alloc(JABBER_NETWORK_BUFFER_SIZE + 1);
if (buffer == NULL) {
ppro->debugLogA("Cannot allocate network buffer, file server connection closed.");
Netlib_CloseHandle(hConnection);
ft->state = FT_ERROR;
if (ft->hFileEvent != NULL)
SetEvent(ft->hFileEvent);
return;
}
ppro->debugLogA("Entering recv loop for this file connection... (ft->s is hConnection)");
int datalen = 0;
while (ft->state != FT_DONE && ft->state != FT_ERROR) {
int recvResult, bytesParsed;
recvResult = Netlib_Recv(hConnection, buffer + datalen, JABBER_NETWORK_BUFFER_SIZE - datalen, 0);
if (recvResult <= 0)
break;
datalen += recvResult;
buffer[datalen] = '\0';
ppro->debugLogA("RECV:%s", buffer);
bytesParsed = ppro->FileSendParse(hConnection, ft, buffer, datalen);
if (bytesParsed < datalen)
memmove(buffer, buffer + bytesParsed, datalen - bytesParsed);
datalen -= bytesParsed;
}
ppro->debugLogA("Closing connection for this file transfer... (ft->s is now hBind)");
Netlib_CloseHandle(hConnection);
ft->s = slisten;
ppro->debugLogA("ft->s is restored to %d", ft->s);
if (ft->hFileEvent != NULL)
SetEvent(ft->hFileEvent);
mir_free(buffer);
}