Hello World!

2018-06-18 00:47:34来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

20170913

#### 四级标题  

### 三级标题   

DWORD WINAPI myServerThread(LPVOID lpParam)
{
	ServerThreadParam *lp =(ServerThreadParam*)lpParam;
	session_s *s = lp->session;
	while(1)
	{
		int state = s->wait_request();
		if (state == s->disconected)
			break;
		request_t * req = s->get_request();

		p_debug("->new request\n  type=%d, flag=%d, len=%d, data=%s\n",
					req->type,req->flag,req->datalen,req->data);
		switch(req->type)
		{
		case (TYPE_LOGIN):
			{
				service_login(s,req);
				break;
			}
		case(TYPE_REGISTER):
			{
				service_register(s,req);
				break;
			}
		case(TYPE_GETUSERINFO):
			{
				service_getuserinfo(s,req);
				break;
			}
		case(TYPE_ADDEVENT):
			{
				service_addevent(s,req);
				break;
			}
		case(TYPE_GETMESSAGE):
			{	
				service_getmessages(s,req);
				break;
			}
		case(TYPE_ADDMESSAGE):
			{
				service_addmessage(s,req);
				break;
			}
		case(TYPE_GETEVENT):
			{
				service_getevent(s,req);
				break;
			}
		case(TYPE_JOINEVENT):
		{
			service_joinevent(s,req);
			break;
		}
		case(TYPE_GETPARTICIPANTS):
		{
			service_getparticipants(s,req);
			break;
		}
		case(TYPE_GETEVENTDETAILBYID):
			{
				service_geteventdetail(s,req);
				break;
			}
		case(TYPE_UPDATEUSERINFO):
			{
				service_updateuserinfo(s,req);
				break;
			}
		default:
			break;
		}
	}
	return 0;
}

  

DWORD WINAPI myServerThread(LPVOID lpParam)

{ /*每一个连接都会有一个这样的处理线程*/

ServerThreadParam *lp =(ServerThreadParam*)lpParam;

session_s *s = lp->session;

while(1)

{

int state = s->wait_request();

if (state == s->disconected)

break;

request_t * req = s->get_request(); //获取请求

//根据不同的请求类型,调用不同的处理逻辑(service_xxx)。

switch(req->type)

{

case (TYPE_LOGIN):

{

service_login(s,req);

break;

}

case(TYPE_REGISTER):

{

service_register(s,req);

break;

}

case(TYPE_GETUSERINFO):

{

service_getuserinfo(s,req);

break;

}

case(TYPE_ADDEVENT):

{

service_addevent(s,req);

break;

}

case(TYPE_GETMESSAGE):

{

service_getmessages(s,req);

break;

}

case(TYPE_ADDMESSAGE):

{

service_addmessage(s,req);

break;

}

case(TYPE_GETEVENT):

{

service_getevent(s,req);

break;

}

case(TYPE_JOINEVENT):

{

service_joinevent(s,req);

break;

}

case(TYPE_GETPARTICIPANTS):

{

service_getparticipants(s,req);

break;

}

case(TYPE_GETEVENTDETAILBYID):

{

service_geteventdetail(s,req);

break;

}

case(TYPE_UPDATEUSERINFO):

{

service_updateuserinfo(s,req);

break;

}

case(TYPE_EXITEVENT):

{

service_exitevent(s,req);

break;

}

case(TYPE_SETEVENTSTATE):

{

service_seteventstate(s,req);

break;

}

case(TYPE_GETEVENTBYCONDITIONS):

{

service_geteventbycondition(s,req);

break;

}

case(TYPE_SETSECURITY):

{

service_setsecurity(s,req);

break;

}

default:

break;

}

}

return 0;

}

  

  1 DWORD WINAPI myServerThread(LPVOID lpParam)
  2 
  3 { /*每一个连接都会有一个这样的处理线程*/
  4 
  5 ServerThreadParam *lp =(ServerThreadParam*)lpParam;
  6 
  7 session_s *s = lp->session;
  8 
  9 while(1)
 10 
 11 {
 12 
 13 int state = s->wait_request();
 14 
 15 if (state == s->disconected)
 16 
 17 break;
 18 
 19 request_t * req = s->get_request(); //获取请求
 20 
 21 //根据不同的请求类型,调用不同的处理逻辑(service_xxx)。
 22 
 23 switch(req->type)
 24 
 25 {
 26 
 27 case (TYPE_LOGIN):
 28 
 29 {
 30 
 31 service_login(s,req);
 32 
 33 break;
 34 
 35 }
 36 
 37 case(TYPE_REGISTER):
 38 
 39 {
 40 
 41 service_register(s,req);
 42 
 43 break;
 44 
 45 }
 46 
 47 case(TYPE_GETUSERINFO):
 48 
 49 {
 50 
 51 service_getuserinfo(s,req);
 52 
 53 break;
 54 
 55 }
 56 
 57 case(TYPE_ADDEVENT):
 58 
 59 {
 60 
 61 service_addevent(s,req);
 62 
 63 break;
 64 
 65 }
 66 
 67 case(TYPE_GETMESSAGE):
 68 
 69 {
 70 
 71 service_getmessages(s,req);
 72 
 73 break;
 74 
 75 }
 76 
 77 case(TYPE_ADDMESSAGE):
 78 
 79 {
 80 
 81 service_addmessage(s,req);
 82 
 83 break;
 84 
 85 }
 86 
 87 case(TYPE_GETEVENT):
 88 
 89 {
 90 
 91 service_getevent(s,req);
 92 
 93 break;
 94 
 95 }
 96 
 97 case(TYPE_JOINEVENT):
 98 
 99 {
100 
101 service_joinevent(s,req);
102 
103 break;
104 
105 }
106 
107 case(TYPE_GETPARTICIPANTS):
108 
109 {
110 
111 service_getparticipants(s,req);
112 
113 break;
114 
115 }
116 
117 case(TYPE_GETEVENTDETAILBYID):
118 
119 {
120 
121 service_geteventdetail(s,req);
122 
123 break;
124 
125 }
126 
127 case(TYPE_UPDATEUSERINFO):
128 
129 {
130 
131 service_updateuserinfo(s,req);
132 
133 break;
134 
135 }
136 
137 case(TYPE_EXITEVENT):
138 
139 {
140 
141 service_exitevent(s,req);
142 
143 break;
144 
145 }
146 
147 case(TYPE_SETEVENTSTATE):
148 
149 {
150 
151 service_seteventstate(s,req);
152 
153 break;
154 
155 }
156 
157 case(TYPE_GETEVENTBYCONDITIONS):
158 
159 {
160 
161 service_geteventbycondition(s,req);
162 
163 break;
164 
165 }
166 
167 case(TYPE_SETSECURITY):
168 
169 {
170 
171 service_setsecurity(s,req);
172 
173 break;
174 
175 }
176 
177 default:
178 
179 break;
180 
181 }
182 
183 }
184 
185 return 0;
186 
187 }
View Code

 

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:C#基础笔记(第九天)

下一篇:(转)非常完善的Log4net详细说明