/PokerPlus0816/Common/ClientProtocol0809.h
C Header | 336 lines | 203 code | 59 blank | 74 comment | 1 complexity | d52ac556807b0f78aae07907e29fc715 MD5 | raw file
- #pragma once
- #pragma pack(push)
- #pragma pack(1)
-
-
- ///////////////////////////////////////////////////////
- #define ios_version
- //comment this if you are using in Windows
-
- ///////////////////////////////////////////////////////
- #define MSGVERSION '_FYW'
- #define BUFFERSIZE 1024*10
- ///////////////////////////////////////////////////////
- typedef enum
- {
- hNull,
- hchLogin, //??????? ??????
- hhcLoginSuccess, //???????? ????????
- hhcLoginFailure, //????
- hchGetRoomSort, //??????????
- hhcSortedRoom, //?????
- hchGetRoomList, //???????????
- hhcRoomList, //??????
- hchGetRoomInfo, //?????????????
- hhcRoomInfo, //??????
- hchEnterRoom, //????
- hhcEnterRoomSuccess, //????
- hhcEnterRoomFailure, //????
-
- hchGetGameInfo, //??????
- hhcReflashGameInfo, //??????
-
- hMax
- } client_server_enum;
- /*****************************************************/
- ///////////////////////////////////////////////////////
- // Structures sent from CLIENT to SERVER //
- ///////////////////////////////////////////////////////
-
- //1.??????
- ///cmdId = hchLogin;
- typedef struct
- {
- char usrName[33]; //?????
- char usrPWD[33]; //????
- char ClientType[8]; //?????
- char ClientVersion[8]; //?????
- }GetUsrInfo,*PGetUsrInfo; //????????
- ///////////////////////////////////////////////////////
-
-
- //2.???????
- ///cmdId = hchGetRoomSort;
- //non struct
- ///////////////////////////////////////////////////////
-
-
- //3.????????
- ///cmdId = hchGetRoomList;
- typedef struct
- {
- int smallblind;
- int maxPlayer;
- bool isVip;
- bool isFastSpeed;
- bool isFull; //isHoldHallRoom;???
- }GetRoomList,*PGetRoomList;
- ///////////////////////////////////////////////////////
-
- //4.????????
- ///cmdId = hhchGetRoomInfo;
- typedef struct
- {
- int roomId;
- } GetRoomInfo,EnterRoom;
-
- //5.????????
- ///cmdId = hchEnterRoom;
-
- //EnterRoom struct
-
- ///////////////////////////////////////////////////////
- /*****************************************************/
-
- ///////////////////////////////////////////////////////
- // Structures sent from SERVER to CLIENT //
- ///////////////////////////////////////////////////////
- typedef struct
- {
- int itemCount;
-
- }RoomUsrInfoCount,RoomSortInfoCount;
- //1.??????
- ///cmdId = hhcLoginSuccess;
- typedef struct
- {
- int usrID; //??ID
- char usrNick[65]; //????
- int usrExperience; //????
- int usrCoins; //????
- long long usrCounters; //????
- char usrInfo[256]; //????json
- } UsrInfo,*PUsrInfo; //???????????
-
- ///cmdId = hhcLoginFailure;
- typedef struct
- {
- short errorCode; //?????0????????1:???????.....
- } LoginErrorInfo; //???????????
-
- ///////////////////////////////////////////////////////
-
- //2.???????
- ///cmdId = hhcSortedRoom;
-
- typedef struct
- {
- long long smallblind;
- } RoomSortInfo,*PRoomSortInfo;
- ///////////////////////////////////////////////////////
-
- //3.????????
- ///cmdId = hhcRoomList;
-
- //?? = [socket readInt];
- typedef struct
- {
- int roomId;
- long long smallblind; //??
- long long ante; //??
- int maxPlayer; //?????
- bool isVip; //???VIP
- bool isFastSpeed; //??
- int playerCount; //??????
- } RoomInfo,*PRoomInfo;
- ///////////////////////////////////////////////////////
-
- //4.????????
- ///cmdId = hhcRoomInfo;
-
- typedef struct
- {
- int usrId;
- char usrNick[65]; //????
- int usrLevel; //????
- long long usrCounters; //????
- char usrInfo[256]; //??????json
- int position; //?????????
-
- } RoomUsrInfo,*PRoomUsrInfo; //??????????
- ///////////////////////////////////////////////////////
-
- //5.????????
- //cmdId = hhcEnterRoomSuccess;
-
- //??????????
-
- //cmdId = hhcEnterRoomFailure;
- typedef struct
- {
- short errorCode;
- }EnterRoomErrorInfo; //??????
- ///////////////////////////////////////////////////////
-
- //6.????????
- //cmdId = hhcReflashGameInfo;
-
- typedef struct
- {
- short state; //????
- //0??? 1??? 2???
- //11??????? 12??????? 13??????? 14???????
- //20??
-
- short turn; //????
- short dealerSeat; //D??
- short boardCardsNum; //????
- short boardCards[5]; //???
-
-
- int money[10]; //????????
- int stake[10]; //??(???????????????????????)
- short potNum; //????
- int pot[10]; //??
-
- bool playing[9]; //????
- bool allin[9]; //????
- char lastCommand[9]; //????? 0Null 1post 2fold 3check 4bet 5call 6raise 7??
- int lastMaxMoney; //???????
-
- }UpdateDesk;
-
- typedef struct
- {
-
- char butId; // 1fold 2check 3bet 4call 5raise
- int butNum; //???
- }ClientCommand;
-
-
- typedef struct
- {
-
- char butId; //???? 0fold/check 2foldAny 3check 4check/callany 5callnow 6callany//-1???
- int butNum; //???
- }SetAutoCommand;
-
-
-
-
-
-
-
- #pragma pack(pop)
- //typedef struct
- //{
- // int roomId;
- //} EnterRoomSuccess;
- ///////////////////////////////////////////////////////
- /*****************************************************/
-
- /* ********************for the ios****************** */
- #ifdef ios_version
- #include <CoreGraphics/CGBase.h>
- ///////////////////////////////////////////////////////
- typedef struct
- {
- int msgVer;
- int msgLen;
- int cmdId;
- } MessageHeader;
-
- CG_INLINE MessageHeader
- NewHeader(int Ver,int Len,int Id)
- {
- MessageHeader msg;
- msg.msgVer = Ver;
- msg.msgLen = Len;
- msg.cmdId = Id;
- return msg;
- }
- ///////////////////////////////////////////////////////
- CG_INLINE GetUsrInfo
- NewAccount(NSData *userName,NSData *userPSW)
- {
- GetUsrInfo ua;
- size_t userNameLen = [userName length]> sizeof(ua.usrName) -1?sizeof(ua.usrName) -1:[userName length];
- size_t userPSWLen = [userPSW length]> sizeof(ua.usrPWD) -1?sizeof(ua.usrPWD) -1:[userPSW length];
-
- memcpy(ua.usrName,[userName bytes],userNameLen);
- ua.usrName[userNameLen] = 0;
-
- memcpy(ua.usrPWD,[userPSW bytes],userPSWLen);
- ua.usrPWD[userPSWLen] = 0;
-
- //show result
-
- printf("usrName:%s\n",ua.usrName);
- printf("usrPSW:%s\n",ua.usrPWD);
-
- return ua;
- }
- ///////////////////////////////////////////////////////
- CG_INLINE UsrInfo
- NewUsrInfo(PUsrInfo uip)
- {
- UsrInfo ui;
- // memset(&ui,0,sizeof(UsrInfo));
- // for (int i =0; i<65; i++) {
- // printf("i:%d,%d\n",i,ui.usrNick[i]);
- // }
- memcpy(&ui,uip,sizeof(UsrInfo));
-
- // for (int i =0; i<65; i++) {
- // printf("i:%d,%d\n",i,ui.usrNick[i]);
- // }
-
- return ui;
- }
- CG_INLINE int
- SizeofUnichar(unichar * source)
- {
- int i=0;
- for (; *(source+i); i++) {
- }
- return i;
- }
- ///////////////////////////////////////////////////////
- typedef struct
- {
- RoomSortInfo * sortedRoom;
- int num;
-
- } RoomSort,*PRoomSort;// for the client and not for the server
- CG_INLINE RoomSort
- NewRoomSort (RoomSortInfo * sorted,int num)
- {
- RoomSort rs;
- rs.sortedRoom = sorted;
- rs.num = num;
- return rs;
- }
- ///////////////////////////////////////////////////////
-
- CG_INLINE RoomInfo
- NewRoomInfo(PRoomInfo rip)
- {
- RoomInfo ri;
- memcpy(&ri,rip,sizeof(RoomInfo));
- return ri;
- }
- ///////////////////////////////////////////////////////
- typedef struct
- {
- RoomInfo * room;
- int num;
- } RoomList,PRoomList;
- CG_INLINE RoomList
- NewRoomList(PRoomInfo ri,int num)
- {
- RoomList rl;
- rl.room = ri;
- rl.num = num;
- return rl;
- }
- CG_INLINE RoomList
- NewRoomListNon()
- {
- RoomList rl;
- rl.room = NULL;
- rl.num = 0;
- return rl;
- }
- ///////////////////////////////////////////////////////
-
- #endif