\GatewayWorker\ProtocolsGatewayProtocol

Gateway 与 Worker 间通讯的二进制协议

struct GatewayProtocol { unsigned int pack_len, unsigned char cmd,//命令字 unsigned int local_ip, unsigned short local_port, unsigned int client_ip, unsigned short client_port, unsigned int connection_id, unsigned char flag, unsigned short gateway_port, unsigned int ext_len, char[ext_len] ext_data, char[pack_length-HEAD_LEN] body//包体 } NCNnNnNCnN

Summary

Methods
Properties
Constants
input()
encode()
decode()
$empty
CMD_ON_CONNECT
CMD_ON_MESSAGE
CMD_ON_CLOSE
CMD_SEND_TO_ONE
CMD_SEND_TO_ALL
CMD_KICK
CMD_DESTROY
CMD_UPDATE_SESSION
CMD_GET_ALL_CLIENT_SESSIONS
CMD_IS_ONLINE
CMD_BIND_UID
CMD_UNBIND_UID
CMD_SEND_TO_UID
CMD_GET_CLIENT_ID_BY_UID
CMD_JOIN_GROUP
CMD_LEAVE_GROUP
CMD_SEND_TO_GROUP
CMD_GET_CLIENT_SESSIONS_BY_GROUP
CMD_GET_CLIENT_COUNT_BY_GROUP
CMD_SELECT
CMD_GET_GROUP_ID_LIST
CMD_UNGROUP
CMD_WORKER_CONNECT
CMD_PING
CMD_GATEWAY_CLIENT_CONNECT
CMD_GET_SESSION_BY_CLIENT_ID
CMD_SET_SESSION
CMD_ON_WEBSOCKET_CONNECT
FLAG_BODY_IS_SCALAR
FLAG_NOT_CALL_ENCODE
HEAD_LEN
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

CMD_ON_CONNECT

CMD_ON_CONNECT = 1

CMD_ON_MESSAGE

CMD_ON_MESSAGE = 3

CMD_ON_CLOSE

CMD_ON_CLOSE = 4

CMD_SEND_TO_ONE

CMD_SEND_TO_ONE = 5

CMD_SEND_TO_ALL

CMD_SEND_TO_ALL = 6

CMD_KICK

CMD_KICK = 7

CMD_DESTROY

CMD_DESTROY = 8

CMD_UPDATE_SESSION

CMD_UPDATE_SESSION = 9

CMD_GET_ALL_CLIENT_SESSIONS

CMD_GET_ALL_CLIENT_SESSIONS = 10

CMD_IS_ONLINE

CMD_IS_ONLINE = 11

CMD_BIND_UID

CMD_BIND_UID = 12

CMD_UNBIND_UID

CMD_UNBIND_UID = 13

CMD_SEND_TO_UID

CMD_SEND_TO_UID = 14

CMD_GET_CLIENT_ID_BY_UID

CMD_GET_CLIENT_ID_BY_UID = 15

CMD_JOIN_GROUP

CMD_JOIN_GROUP = 20

CMD_LEAVE_GROUP

CMD_LEAVE_GROUP = 21

CMD_SEND_TO_GROUP

CMD_SEND_TO_GROUP = 22

CMD_GET_CLIENT_SESSIONS_BY_GROUP

CMD_GET_CLIENT_SESSIONS_BY_GROUP = 23

CMD_GET_CLIENT_COUNT_BY_GROUP

CMD_GET_CLIENT_COUNT_BY_GROUP = 24

CMD_SELECT

CMD_SELECT = 25

CMD_GET_GROUP_ID_LIST

CMD_GET_GROUP_ID_LIST = 26

CMD_UNGROUP

CMD_UNGROUP = 27

CMD_WORKER_CONNECT

CMD_WORKER_CONNECT = 200

CMD_PING

CMD_PING = 201

CMD_GATEWAY_CLIENT_CONNECT

CMD_GATEWAY_CLIENT_CONNECT = 202

CMD_GET_SESSION_BY_CLIENT_ID

CMD_GET_SESSION_BY_CLIENT_ID = 203

CMD_SET_SESSION

CMD_SET_SESSION = 204

CMD_ON_WEBSOCKET_CONNECT

CMD_ON_WEBSOCKET_CONNECT = 205

FLAG_BODY_IS_SCALAR

FLAG_BODY_IS_SCALAR = 1

FLAG_NOT_CALL_ENCODE

FLAG_NOT_CALL_ENCODE = 2

HEAD_LEN

HEAD_LEN = 28 : integer

包头长度

Properties

$empty

$empty : 

Type

Methods

input()

input(string  $buffer) : integer

返回包长度

Parameters

string $buffer

Returns

integer —

return current package length

encode()

encode(mixed  $data) : string

获取整个包的 buffer

Parameters

mixed $data

Returns

string

decode()

decode(string  $buffer) : array

从二进制数据转换为数组

Parameters

string $buffer

Returns

array