本文整理汇总了C++中CJabberProto::Log方法的典型用法代码示例。如果您正苦于以下问题:C++ CJabberProto::Log方法的具体用法?C++ CJabberProto::Log怎么用?C++ CJabberProto::Log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CJabberProto
的用法示例。
在下文中一共展示了CJabberProto::Log方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: JabberByteSendConnection
void JabberByteSendConnection( HANDLE hConn, DWORD /*dwRemoteIP*/, void* extra )
{
CJabberProto* ppro = ( CJabberProto* )extra;
TCHAR szPort[8];
JABBER_BYTE_TRANSFER *jbt;
int recvResult, bytesParsed;
HANDLE hListen;
JABBER_LIST_ITEM *item;
char* buffer;
int datalen;
NETLIBCONNINFO connInfo = { sizeof(connInfo) };
CallService(MS_NETLIB_GETCONNECTIONINFO, (WPARAM)hConn, (LPARAM)&connInfo);
mir_sntprintf( szPort, SIZEOF( szPort ), _T("%u"), connInfo.wPort );
ppro->Log( "bytestream_send_connection incoming connection accepted: %s", connInfo.szIpPort );
if (( item = ppro->ListGetItemPtr( LIST_BYTE, szPort )) == NULL ) {
ppro->Log( "No bytestream session is currently active, connection closed." );
Netlib_CloseHandle( hConn );
return;
}
jbt = item->jbt;
if (( buffer = ( char* )mir_alloc( JABBER_NETWORK_BUFFER_SIZE )) == NULL ) {
ppro->Log( "bytestream_send cannot allocate network buffer, connection closed." );
jbt->state = JBT_ERROR;
Netlib_CloseHandle( hConn );
if ( jbt->hEvent != NULL ) SetEvent( jbt->hEvent );
return;
}
hListen = jbt->hConn;
jbt->hConn = hConn;
jbt->state = JBT_INIT;
datalen = 0;
while ( jbt->state!=JBT_DONE && jbt->state!=JBT_ERROR ) {
recvResult = Netlib_Recv( hConn, buffer+datalen, JABBER_NETWORK_BUFFER_SIZE-datalen, 0 );
if ( recvResult <= 0 )
break;
datalen += recvResult;
bytesParsed = ppro->ByteSendParse( hConn, jbt, buffer, datalen );
if ( bytesParsed < datalen )
memmove( buffer, buffer+bytesParsed, datalen-bytesParsed );
datalen -= bytesParsed;
}
if ( jbt->hConn )
Netlib_CloseHandle( jbt->hConn );
ppro->Log( "bytestream_send_connection closing connection" );
jbt->hConn = hListen;
mir_free( buffer );
if ( jbt->hEvent != NULL )
SetEvent( jbt->hEvent );
}
示例2: JabberByteSendConnection
void JabberByteSendConnection( HANDLE hConn, DWORD /*dwRemoteIP*/, void* extra )
{
CJabberProto* ppro = ( CJabberProto* )extra;
SOCKET s;
SOCKADDR_IN saddr;
int len;
WORD localPort;
TCHAR szPort[8];
JABBER_BYTE_TRANSFER *jbt;
int recvResult, bytesParsed;
HANDLE hListen;
JABBER_LIST_ITEM *item;
char* buffer;
int datalen;
localPort = 0;
if (( s = JCallService( MS_NETLIB_GETSOCKET, ( WPARAM ) hConn, 0 )) != INVALID_SOCKET ) {
len = sizeof( saddr );
if ( getsockname( s, ( SOCKADDR * ) &saddr, &len ) != SOCKET_ERROR )
localPort = ntohs( saddr.sin_port );
}
if ( localPort == 0 ) {
ppro->Log( "bytestream_send_connection unable to determine the local port, connection closed." );
Netlib_CloseHandle( hConn );
return;
}
mir_sntprintf( szPort, SIZEOF( szPort ), _T("%d"), localPort );
ppro->Log( "bytestream_send_connection incoming connection accepted: local_port=" TCHAR_STR_PARAM, szPort );
if (( item = ppro->ListGetItemPtr( LIST_BYTE, szPort )) == NULL ) {
ppro->Log( "No bytestream session is currently active, connection closed." );
Netlib_CloseHandle( hConn );
return;
}
jbt = item->jbt;
if (( buffer = ( char* )mir_alloc( JABBER_NETWORK_BUFFER_SIZE )) == NULL ) {
ppro->Log( "bytestream_send cannot allocate network buffer, connection closed." );
jbt->state = JBT_ERROR;
Netlib_CloseHandle( hConn );
if ( jbt->hEvent != NULL ) SetEvent( jbt->hEvent );
return;
}
hListen = jbt->hConn;
jbt->hConn = hConn;
jbt->state = JBT_INIT;
datalen = 0;
while ( jbt->state!=JBT_DONE && jbt->state!=JBT_ERROR ) {
recvResult = Netlib_Recv( hConn, buffer+datalen, JABBER_NETWORK_BUFFER_SIZE-datalen, 0 );
if ( recvResult <= 0 )
break;
datalen += recvResult;
bytesParsed = ppro->ByteSendParse( hConn, jbt, buffer, datalen );
if ( bytesParsed < datalen )
memmove( buffer, buffer+bytesParsed, datalen-bytesParsed );
datalen -= bytesParsed;
}
if ( jbt->hConn )
Netlib_CloseHandle( jbt->hConn );
ppro->Log( "bytestream_send_connection closing connection" );
jbt->hConn = hListen;
mir_free( buffer );
if ( jbt->hEvent != NULL )
SetEvent( jbt->hEvent );
}
示例3: JabberFileServerConnection
void JabberFileServerConnection( JABBER_SOCKET hConnection, DWORD /*dwRemoteIP*/, void* extra )
{
CJabberProto* ppro = ( CJabberProto* )extra;
WORD localPort = 0;
SOCKET s = JCallService( MS_NETLIB_GETSOCKET, ( WPARAM ) hConnection, 0 );
if ( s != INVALID_SOCKET ) {
SOCKADDR_IN saddr;
int len = sizeof( saddr );
if ( getsockname( s, ( SOCKADDR * ) &saddr, &len ) != SOCKET_ERROR ) {
localPort = ntohs( saddr.sin_port );
}
}
if ( localPort == 0 ) {
ppro->Log( "Unable to determine the local port, file server connection closed." );
Netlib_CloseHandle( hConnection );
return;
}
TCHAR szPort[20];
mir_sntprintf( szPort, SIZEOF( szPort ), _T("%d"), localPort );
ppro->Log( "File server incoming connection accepted: local_port=" TCHAR_STR_PARAM, szPort );
JABBER_LIST_ITEM *item = ppro->ListGetItemPtr( LIST_FILE, szPort );
if ( item == NULL ) {
ppro->Log( "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->Log( "Set ft->s to %d ( saving %d )", hConnection, slisten );
char* buffer = ( char* )mir_alloc( JABBER_NETWORK_BUFFER_SIZE+1 );
if ( buffer == NULL ) {
ppro->Log( "Cannot allocate network buffer, file server connection closed." );
Netlib_CloseHandle( hConnection );
ft->state = FT_ERROR;
if ( ft->hFileEvent != NULL )
SetEvent( ft->hFileEvent );
return;
}
ppro->Log( "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->Log( "RECV:%s", buffer );
bytesParsed = ppro->FileSendParse( hConnection, ft, buffer, datalen );
if ( bytesParsed < datalen )
memmove( buffer, buffer+bytesParsed, datalen-bytesParsed );
datalen -= bytesParsed;
}
ppro->Log( "Closing connection for this file transfer... ( ft->s is now hBind )" );
Netlib_CloseHandle( hConnection );
ft->s = slisten;
ppro->Log( "ft->s is restored to %d", ft->s );
if ( ft->hFileEvent != NULL )
SetEvent( ft->hFileEvent );
mir_free( buffer );
}