PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/PokerPlus0816/Common/ClientProtocol0809.h

http://pokerplus.googlecode.com/
C Header | 336 lines | 203 code | 59 blank | 74 comment | 1 complexity | d52ac556807b0f78aae07907e29fc715 MD5 | raw file
  1. #pragma once
  2. #pragma pack(push)
  3. #pragma pack(1)
  4. ///////////////////////////////////////////////////////
  5. #define ios_version
  6. //comment this if you are using in Windows
  7. ///////////////////////////////////////////////////////
  8. #define MSGVERSION '_FYW'
  9. #define BUFFERSIZE 1024*10
  10. ///////////////////////////////////////////////////////
  11. typedef enum
  12. {
  13. hNull,
  14. hchLogin, //??????? ??????
  15. hhcLoginSuccess, //???????? ????????
  16. hhcLoginFailure, //????
  17. hchGetRoomSort, //??????????
  18. hhcSortedRoom, //?????
  19. hchGetRoomList, //???????????
  20. hhcRoomList, //??????
  21. hchGetRoomInfo, //?????????????
  22. hhcRoomInfo, //??????
  23. hchEnterRoom, //????
  24. hhcEnterRoomSuccess, //????
  25. hhcEnterRoomFailure, //????
  26. hchGetGameInfo, //??????
  27. hhcReflashGameInfo, //??????
  28. hMax
  29. } client_server_enum;
  30. /*****************************************************/
  31. ///////////////////////////////////////////////////////
  32. // Structures sent from CLIENT to SERVER //
  33. ///////////////////////////////////////////////////////
  34. //1.??????
  35. ///cmdId = hchLogin;
  36. typedef struct
  37. {
  38. char usrName[33]; //?????
  39. char usrPWD[33]; //????
  40. char ClientType[8]; //?????
  41. char ClientVersion[8]; //?????
  42. }GetUsrInfo,*PGetUsrInfo; //????????
  43. ///////////////////////////////////////////////////////
  44. //2.???????
  45. ///cmdId = hchGetRoomSort;
  46. //non struct
  47. ///////////////////////////////////////////////////////
  48. //3.????????
  49. ///cmdId = hchGetRoomList;
  50. typedef struct
  51. {
  52. int smallblind;
  53. int maxPlayer;
  54. bool isVip;
  55. bool isFastSpeed;
  56. bool isFull; //isHoldHallRoom;???
  57. }GetRoomList,*PGetRoomList;
  58. ///////////////////////////////////////////////////////
  59. //4.????????
  60. ///cmdId = hhchGetRoomInfo;
  61. typedef struct
  62. {
  63. int roomId;
  64. } GetRoomInfo,EnterRoom;
  65. //5.????????
  66. ///cmdId = hchEnterRoom;
  67. //EnterRoom struct
  68. ///////////////////////////////////////////////////////
  69. /*****************************************************/
  70. ///////////////////////////////////////////////////////
  71. // Structures sent from SERVER to CLIENT //
  72. ///////////////////////////////////////////////////////
  73. typedef struct
  74. {
  75. int itemCount;
  76. }RoomUsrInfoCount,RoomSortInfoCount;
  77. //1.??????
  78. ///cmdId = hhcLoginSuccess;
  79. typedef struct
  80. {
  81. int usrID; //??ID
  82. char usrNick[65]; //????
  83. int usrExperience; //????
  84. int usrCoins; //????
  85. long long usrCounters; //????
  86. char usrInfo[256]; //????json
  87. } UsrInfo,*PUsrInfo; //???????????
  88. ///cmdId = hhcLoginFailure;
  89. typedef struct
  90. {
  91. short errorCode; //?????0????????1:???????.....
  92. } LoginErrorInfo; //???????????
  93. ///////////////////////////////////////////////////////
  94. //2.???????
  95. ///cmdId = hhcSortedRoom;
  96. typedef struct
  97. {
  98. long long smallblind;
  99. } RoomSortInfo,*PRoomSortInfo;
  100. ///////////////////////////////////////////////////////
  101. //3.????????
  102. ///cmdId = hhcRoomList;
  103. //?? = [socket readInt];
  104. typedef struct
  105. {
  106. int roomId;
  107. long long smallblind; //??
  108. long long ante; //??
  109. int maxPlayer; //?????
  110. bool isVip; //???VIP
  111. bool isFastSpeed; //??
  112. int playerCount; //??????
  113. } RoomInfo,*PRoomInfo;
  114. ///////////////////////////////////////////////////////
  115. //4.????????
  116. ///cmdId = hhcRoomInfo;
  117. typedef struct
  118. {
  119. int usrId;
  120. char usrNick[65]; //????
  121. int usrLevel; //????
  122. long long usrCounters; //????
  123. char usrInfo[256]; //??????json
  124. int position; //?????????
  125. } RoomUsrInfo,*PRoomUsrInfo; //??????????
  126. ///////////////////////////////////////////////////////
  127. //5.????????
  128. //cmdId = hhcEnterRoomSuccess;
  129. //??????????
  130. //cmdId = hhcEnterRoomFailure;
  131. typedef struct
  132. {
  133. short errorCode;
  134. }EnterRoomErrorInfo; //??????
  135. ///////////////////////////////////////////////////////
  136. //6.????????
  137. //cmdId = hhcReflashGameInfo;
  138. typedef struct
  139. {
  140. short state; //????
  141. //0??? 1??? 2???
  142. //11??????? 12??????? 13??????? 14???????
  143. //20??
  144. short turn; //????
  145. short dealerSeat; //D??
  146. short boardCardsNum; //????
  147. short boardCards[5]; //???
  148. int money[10]; //????????
  149. int stake[10]; //??(???????????????????????)
  150. short potNum; //????
  151. int pot[10]; //??
  152. bool playing[9]; //????
  153. bool allin[9]; //????
  154. char lastCommand[9]; //????? 0Null 1post 2fold 3check 4bet 5call 6raise 7??
  155. int lastMaxMoney; //???????
  156. }UpdateDesk;
  157. typedef struct
  158. {
  159. char butId; // 1fold 2check 3bet 4call 5raise
  160. int butNum; //???
  161. }ClientCommand;
  162. typedef struct
  163. {
  164. char butId; //???? 0fold/check 2foldAny 3check 4check/callany 5callnow 6callany//-1???
  165. int butNum; //???
  166. }SetAutoCommand;
  167. #pragma pack(pop)
  168. //typedef struct
  169. //{
  170. // int roomId;
  171. //} EnterRoomSuccess;
  172. ///////////////////////////////////////////////////////
  173. /*****************************************************/
  174. /* ********************for the ios****************** */
  175. #ifdef ios_version
  176. #include <CoreGraphics/CGBase.h>
  177. ///////////////////////////////////////////////////////
  178. typedef struct
  179. {
  180. int msgVer;
  181. int msgLen;
  182. int cmdId;
  183. } MessageHeader;
  184. CG_INLINE MessageHeader
  185. NewHeader(int Ver,int Len,int Id)
  186. {
  187. MessageHeader msg;
  188. msg.msgVer = Ver;
  189. msg.msgLen = Len;
  190. msg.cmdId = Id;
  191. return msg;
  192. }
  193. ///////////////////////////////////////////////////////
  194. CG_INLINE GetUsrInfo
  195. NewAccount(NSData *userName,NSData *userPSW)
  196. {
  197. GetUsrInfo ua;
  198. size_t userNameLen = [userName length]> sizeof(ua.usrName) -1?sizeof(ua.usrName) -1:[userName length];
  199. size_t userPSWLen = [userPSW length]> sizeof(ua.usrPWD) -1?sizeof(ua.usrPWD) -1:[userPSW length];
  200. memcpy(ua.usrName,[userName bytes],userNameLen);
  201. ua.usrName[userNameLen] = 0;
  202. memcpy(ua.usrPWD,[userPSW bytes],userPSWLen);
  203. ua.usrPWD[userPSWLen] = 0;
  204. //show result
  205. printf("usrName:%s\n",ua.usrName);
  206. printf("usrPSW:%s\n",ua.usrPWD);
  207. return ua;
  208. }
  209. ///////////////////////////////////////////////////////
  210. CG_INLINE UsrInfo
  211. NewUsrInfo(PUsrInfo uip)
  212. {
  213. UsrInfo ui;
  214. // memset(&ui,0,sizeof(UsrInfo));
  215. // for (int i =0; i<65; i++) {
  216. // printf("i:%d,%d\n",i,ui.usrNick[i]);
  217. // }
  218. memcpy(&ui,uip,sizeof(UsrInfo));
  219. // for (int i =0; i<65; i++) {
  220. // printf("i:%d,%d\n",i,ui.usrNick[i]);
  221. // }
  222. return ui;
  223. }
  224. CG_INLINE int
  225. SizeofUnichar(unichar * source)
  226. {
  227. int i=0;
  228. for (; *(source+i); i++) {
  229. }
  230. return i;
  231. }
  232. ///////////////////////////////////////////////////////
  233. typedef struct
  234. {
  235. RoomSortInfo * sortedRoom;
  236. int num;
  237. } RoomSort,*PRoomSort;// for the client and not for the server
  238. CG_INLINE RoomSort
  239. NewRoomSort (RoomSortInfo * sorted,int num)
  240. {
  241. RoomSort rs;
  242. rs.sortedRoom = sorted;
  243. rs.num = num;
  244. return rs;
  245. }
  246. ///////////////////////////////////////////////////////
  247. CG_INLINE RoomInfo
  248. NewRoomInfo(PRoomInfo rip)
  249. {
  250. RoomInfo ri;
  251. memcpy(&ri,rip,sizeof(RoomInfo));
  252. return ri;
  253. }
  254. ///////////////////////////////////////////////////////
  255. typedef struct
  256. {
  257. RoomInfo * room;
  258. int num;
  259. } RoomList,PRoomList;
  260. CG_INLINE RoomList
  261. NewRoomList(PRoomInfo ri,int num)
  262. {
  263. RoomList rl;
  264. rl.room = ri;
  265. rl.num = num;
  266. return rl;
  267. }
  268. CG_INLINE RoomList
  269. NewRoomListNon()
  270. {
  271. RoomList rl;
  272. rl.room = NULL;
  273. rl.num = 0;
  274. return rl;
  275. }
  276. ///////////////////////////////////////////////////////
  277. #endif