1
/***************************************************************************
2
csearchsocket.cpp - description
4
begin : Thu May 27 2004
5
copyright : (C) 2004 by Mathias K�ster
6
email : mathen@users.berlios.de
7
***************************************************************************/
9
/***************************************************************************
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
16
***************************************************************************/
24
#include <dclib/dcos.h>
25
#include <dclib/dclib.h>
26
#include <dclib/core/cstring.h>
27
#include <dclib/cmessagehandler.h>
29
#include "csearchsocket.h"
32
CSearchSocket::CSearchSocket()
38
CSearchSocket::~CSearchSocket()
40
SetCallBackFunction(0);
44
int CSearchSocket::HandleMessage( char * c, int )
49
CMessageHandler MessageHandler;
54
while( (type=MessageHandler.Parse(&s,p,Object=0)) != DC_MESSAGE_PARSE_ERROR )
58
case DC_MESSAGE_SEARCHRESULT:
76
((CDCMessage*)Object)->m_eType = type;
78
if ( m_pCallback != 0 )
80
err = m_pCallback->notify( this, Object );
85
printf("CallBack failed (state)...\n");
95
void CSearchSocket::DataAvailable( const char * buffer, int len )
101
// add traffic control
102
CSocket::m_Traffic.AddTraffic(ettCONTROLRX,len);
104
// add '|' for parser
107
HandleMessage( (char*)m_sBuffer.Data(), m_sBuffer.Length() );
111
void CSearchSocket::ConnectionState( eConnectionState state )
115
CMessageConnectionState *Object;
117
Object = new CMessageConnectionState();
119
Object->m_eState = state;
120
Object->m_sMessage = GetSocketError();
122
if ( m_pCallback != 0 )
124
err = m_pCallback->notify( this, Object );
129
printf("CallBack failed (state)...\n");