forked from p308945/MyNetWorkLib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyServerTask.cpp
More file actions
54 lines (52 loc) · 1.48 KB
/
MyServerTask.cpp
File metadata and controls
54 lines (52 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* =====================================================================================
*
* Filename: MyServerTask.cpp
*
* Description: server tcp connection
*
* Version: 1.0
* Created: 09/28/2015 10:53:59 AM
* Revision: none
* Compiler: gcc
*
* Author: huangyun (hy), 895175589@qq.com
* Organization:
*
* =====================================================================================
*/
#include "MyServerTask.h"
#include "../proto/BaseCmd.h"
namespace MyNameSpace
{
bool MyServerTask::cmdParse(const char *msg, int len)
{
// mDispatcher.dispatch(msg, len);
if (mInnerDispatcher && mOutterDispatcher)
{
const Command::BaseCommand *pCmd = reinterpret_cast<const Command::BaseCommand *>(msg);
// std::cout<<"msg: "<<msg<<" Id:"<<pCmd->mCmdId<<" type: "<<(char)pCmd->mType<<" data: "<<pCmd->data<<" len: "<<len<<std::endl;
// std::cout<<"msg: "<<msg<<" Id:"<<pCmd->mCmdId<<" type: "<<(char)pCmd->mType<<" len: "<<len<<std::endl;
switch(pCmd->mType)
{
case Command::COMMAND_TYPE::INNER:
{
mInnerDispatcher->dispatcher(pCmd, len, getId());
}
break;
case Command::COMMAND_TYPE::OUTTER:
{
mOutterDispatcher->dispatcher(pCmd, len, getId());
}
break;
default:
{
std::cerr<<"file: "<<__FILE__<<" function: "<<__FUNCTION__<<" line: "<<__LINE__<<" Id: "<<pCmd->mCmdId<<" error"<<std::endl;
return false;
}
break;
}
}
return true;
}
}