DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:indexmenu

This is an old revision of the document!


Socket代理协议说明

香港棋牌客户端请求PHP接口方式,由客户端发接口给Socket Server,Socket Server转发给PHP,PHP处理完毕返回结果给Socket Server再转回给客户端。

【客户端】 ←— 长连接 —→ 【Socket Server】 <…. 短连接 ….> 【PHP】(半透明转发协议)

地方棋牌PHP在使用标准REST接口的基础上,接收返回数据时做了处理,以保证接口完全兼容新版斗地主的协议。下面对兼容前后的请求方式举例说明。

'REST请求(POST源内容):' {“app”:103000,“ssid”:“sdfsdfd2cc3dssfd2”,“action”:“user.getuifno”,“debug”:0} 'REST返回:(如请求数据中存在字段“compatible”则返回结果格式则与半透明转发时一致)' <pre>{“code”:200,“error”:“”,“result”:{“mid”:2,“app_id”:103000,“reg_time”:1388109996 … }}</pre> '半透明转发请求(POST源内容):' <pre>m=hand&p=out&act=1&index=2&cmd=1&info={“mid”:1,“php”:“{\”cmd\“:1,\”seq\“:13982343234,\”app\“:103000,\”ssid\“:\”sdfsdfd2cc3dssfd2\“,\”action\“:\”user.getuifno\“,\”debug\“:0}”}</pre> 使用POST传参,'m、p、act、index、info.mid'均为Socket Server添加的兼容字段,客户端发送的源数据被添加到了'info.php'字段中(JSON中包含的JSON),并且客户端多加了'cmd'字段和'seq'字段用于自身处理。

'cmd': 用于标识命令,返回时原样返回

'seq': 请求标识请求,返回时原样返回(建议客户端为每一个php请求分配一个不同序列号,收到返回结果时根据本字段区分对应请求)

'__debug': 用于指示PHP记录下用户请求数据与返回结果,用于跟踪用户请求定位问题,每次启动应用需要客户端将值设置为0,有需要时告知用户打开客户端的开关,将该值修改为1,但下次启动依旧需要清0。

'半透明转发返回:' <pre>{“status”:0,“type”:0,“msg”:“”,“cmd”:1,“seq”:13982343234,“info”:{“mid”:2,“app_id”:103000,“reg_time”:1388109996 … }}</pre> REST接口中的'code'字段演变为了'status'和'type'两个字段,'error'改名为'msg','result'改名为'info',客户端发送过来的'cmd'字段和'seq'字段追加到结果中以便客户端区分返回的结果属于哪个接口。

plugin/indexmenu.1456737617.txt.gz · Last modified: 2016-02-29 10:20 by 14.215.134.131

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki