PageRenderTime 13ms CodeModel.GetById 7ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/TGame/TTools/MysqlStressTest/MysqlStressTestManager/MysqlStressTestManager/Source/MessageHandler.cpp

http://awoe.googlecode.com/
C++ | 71 lines | 58 code | 6 blank | 7 comment | 3 complexity | 405e74b9435a7ad0862efb691b122864 MD5 | raw file
 1//////////////////////////////////////////////////////////////////////////
 2// MessageHandler.cpp													//
 3//																		//
 4// WYJ																	//
 5// 2010.4																//
 6//																		//
 7//////////////////////////////////////////////////////////////////////////
 8
 9#include "stdafx.h"
10#include "MessageHandler.h"
11#include "ConnecterManager.h"
12
13MessageHandler::MessageHandler( ConnecterManager * pConnecterManager )
14: m_pConnecterManager( pConnecterManager )
15{
16}
17
18MessageHandler::~MessageHandler( void )
19{
20}
21
22void MessageHandler::HandleMessage( int index, const char * msg )
23{
24	MessageHead* pMessage = (MessageHead *)msg;
25	if ( pMessage->msgCate != MsgCategory::MYSQL_TEST )
26	{
27		char buf[1024];
28		sprintf_s( buf, 1024, "Receive a undefine message category(%x)", pMessage->msgCate );
29		MessageBox( NULL, buf, 0, 0 );
30		return;
31	}
32	switch ( pMessage->msgType )
33	{
34	case MsgType::None:
35		{
36			char buf[1024];
37			sprintf_s( buf, 1024, "Receive a message type is None(%x)", pMessage->msgType );
38			MessageBox( NULL, buf, 0, 0 );
39			return;
40		}
41		break;
42	case MsgType::Init:
43		HandleInitMessage( index, pMessage );
44		break;
45	case MsgType::Ready:
46		break;
47	case MsgType::Running:
48		break;
49	case MsgType::Stop:
50		break;
51	case MsgType::Sucess:
52		break;
53	case MsgType::Interrupt:
54		break;
55	default:
56		{
57			char buf[1024];
58			sprintf_s( buf, 1024, "Receive an undefine message type(%x)", pMessage->msgType );
59			MessageBox( NULL, buf, 0, 0 );
60			return;
61		}
62		break;
63	}
64}
65
66void MessageHandler::HandleInitMessage( int index, const MessageHead* pMessage )
67{
68	Msg_Init* pMsg = (Msg_Init *)pMessage;
69
70	m_pConnecterManager->InitConnecter( index, pMsg->threadID );
71}