forked from jimingmin/frame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frame_msghandle.cpp
188 lines (150 loc) · 5.11 KB
/
frame_msghandle.cpp
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*
* frame_msghandle.cpp
*
* Created on: 2014年1月23日
* Author: jimm
*/
#include "frame_msgmap.h"
#include "frame_msghandle.h"
#include "frame.h"
#include <stddef.h>
FRAME_NAMESPACE_BEGIN
int32_t FrameMsgCallBack(CFrame *pFrame, CMsgMapDecl &stMsgMap, int32_t nMsgID, va_list ap)
{
MsgEntry *pEntry = stMsgMap.GetMsgEntry(nMsgID);
if(pEntry == NULL)
{
return -1;
}
int32_t nRet = 0;
ProcCodeFlag flag = pEntry->m_nProcCodeFlag;
// va_list ap;
// va_start(ap, nMsgID);
switch(flag)
{
case enmProcCodeFlag_i32_pco_pmh_pmb:
{
CBaseObject *pObj = va_arg(ap, CBaseObject *);
uint8_t *pBuf = va_arg(ap, uint8_t *);
int32_t nBufSize = va_arg(ap, int32_t);
i32_pco_pmh_pmb Proc = pEntry->m_stEntryParam.EP_i32_pco_pmh_pmb.m_pMsgHandleProc;
CBaseObject *pInstance = pEntry->m_stEntryParam.EP_i32_pco_pmh_pmb.m_pObject;
IMsgHead *pMsgHead = pEntry->m_stEntryParam.EP_i32_pco_pmh_pmb.m_pMsgHead;
IMsgBody *pMsgBody = pEntry->m_stEntryParam.EP_i32_pco_pmh_pmb.m_pMsgBody;
uint32_t nOffset = 0;
if(pMsgHead->Decode(pBuf, nBufSize, nOffset) != 0)
{
return 2;
}
if(pMsgBody->Decode(pBuf, nBufSize, nOffset) != 0)
{
return 2;
}
pFrame->Dump(NULL, pMsgHead, pMsgBody, "recv ");
nRet = (pInstance->*Proc)(pObj, pMsgHead, pMsgBody);
}
break;
case enmProcCodeFlag_i32_pco_pu8_i32:
{
CBaseObject *pObj = va_arg(ap, CBaseObject *);
uint8_t *pBuf = va_arg(ap, uint8_t *);
int32_t nBufSize = va_arg(ap, int32_t);
i32_pco_pu8_i32 Proc = pEntry->m_stEntryParam.EP_i32_pco_pu8_i32.m_pMsgHandleProc;
CBaseObject *pInstance = pEntry->m_stEntryParam.EP_i32_pco_pu8_i32.m_pObject;
nRet = (pInstance->*Proc)(pObj, pBuf, nBufSize);
}
break;
case enmProcCodeFlag_i32_pco_pmh_pmb_pu8_i32:
{
CBaseObject *pObj = va_arg(ap, CBaseObject *);
uint8_t *pBuf = va_arg(ap, uint8_t *);
int32_t nBufSize = va_arg(ap, int32_t);
i32_pco_pmh_pmb_pu8_i32 Proc = pEntry->m_stEntryParam.EP_i32_pco_pmh_pmb_pu8_i32.m_pMsgHandleProc;
CBaseObject *pInstance = pEntry->m_stEntryParam.EP_i32_pco_pmh_pmb_pu8_i32.m_pObject;
IMsgHead *pMsgHead = pEntry->m_stEntryParam.EP_i32_pco_pmh_pmb_pu8_i32.m_pMsgHead;
IMsgBody *pMsgBody = pEntry->m_stEntryParam.EP_i32_pco_pmh_pmb_pu8_i32.m_pMsgBody;
uint32_t nOffset = 0;
if(pMsgHead->Decode(pBuf, nBufSize, nOffset) != 0)
{
return 2;
}
if(pMsgBody->Decode(pBuf, nBufSize, nOffset) != 0)
{
return 2;
}
pFrame->Dump(NULL, pMsgHead, pMsgBody, "recv ");
nRet = (pInstance->*Proc)(pObj, pMsgHead, pMsgBody, pBuf, nBufSize);
}
break;
case enmProcCodeFlag_i32_pco_pmh_pu8_i32:
{
CBaseObject *pObj = va_arg(ap, CBaseObject *);
uint8_t *pBuf = va_arg(ap, uint8_t *);
int32_t nBufSize = va_arg(ap, int32_t);
i32_pco_pmh_pu8_i32 Proc = pEntry->m_stEntryParam.EP_i32_pco_pmh_pu8_i32.m_pMsgHandleProc;
CBaseObject *pInstance = pEntry->m_stEntryParam.EP_i32_pco_pmh_pu8_i32.m_pObject;
IMsgHead *pMsgHead = pEntry->m_stEntryParam.EP_i32_pco_pmh_pu8_i32.m_pMsgHead;
uint32_t nOffset = 0;
if(pMsgHead->Decode(pBuf, nBufSize, nOffset) != 0)
{
return 2;
}
pFrame->Dump(NULL, pMsgHead, NULL, "recv ");
nRet = (pInstance->*Proc)(pObj, pMsgHead, pBuf, nBufSize);
}
break;
case enmProcCodeFlag_i32_pch_pmh_pmb_pu8_i32:
{
uint8_t *pBuf = va_arg(ap, uint8_t *);
int32_t nBufSize = va_arg(ap, int32_t);
i32_pch_pmh_pmb_pu8_i32 Proc = pEntry->m_stEntryParam.EP_i32_pch_pmh_pmb_pu8_i32.m_pMsgHandleProc;
CBaseObject *pInstance = pEntry->m_stEntryParam.EP_i32_pch_pmh_pmb_pu8_i32.m_pObject;
ICtlHead *pCtlHead = pEntry->m_stEntryParam.EP_i32_pch_pmh_pmb_pu8_i32.m_pCtlHead;
IMsgHead *pMsgHead = pEntry->m_stEntryParam.EP_i32_pch_pmh_pmb_pu8_i32.m_pMsgHead;
IMsgBody *pMsgBody = pEntry->m_stEntryParam.EP_i32_pch_pmh_pmb_pu8_i32.m_pMsgBody;
uint32_t nOffset = 0;
if(pCtlHead->Decode(pBuf, nBufSize, nOffset) != 0)
{
return 2;
}
if(pMsgHead->Decode(pBuf, nBufSize, nOffset) != 0)
{
return 2;
}
if(pMsgBody->Decode(pBuf, nBufSize, nOffset) != 0)
{
return 2;
}
pFrame->Dump(pCtlHead, pMsgHead, pMsgBody, "recv ");
nRet = (pInstance->*Proc)(pCtlHead, pMsgHead, pMsgBody, pBuf, nBufSize);
}
break;
case enmProcCodeFlag_i32_pch_pmh_pu8_i32:
{
uint8_t *pBuf = va_arg(ap, uint8_t *);
int32_t nBufSize = va_arg(ap, int32_t);
i32_pch_pmh_pu8_i32 Proc = pEntry->m_stEntryParam.EP_i32_pch_pmh_pu8_i32.m_pMsgHandleProc;
CBaseObject *pInstance = pEntry->m_stEntryParam.EP_i32_pch_pmh_pu8_i32.m_pObject;
ICtlHead *pCtlHead = pEntry->m_stEntryParam.EP_i32_pch_pmh_pu8_i32.m_pCtlHead;
IMsgHead *pMsgHead = pEntry->m_stEntryParam.EP_i32_pch_pmh_pu8_i32.m_pMsgHead;
uint32_t nOffset = 0;
if(pCtlHead->Decode(pBuf, nBufSize, nOffset) != 0)
{
return 2;
}
if(pMsgHead->Decode(pBuf, nBufSize, nOffset) != 0)
{
return 2;
}
pFrame->Dump(pCtlHead, pMsgHead, NULL, "recv ");
nRet = (pInstance->*Proc)(pCtlHead, pMsgHead, pBuf, nBufSize);
}
break;
default:
nRet = 1;
break;
}
// va_end(ap);
return nRet;
}
FRAME_NAMESPACE_END