/** * @brief 触发用户事件,用于执行 登录、登出 等操作 * @return 0 表示执行成功 false 表示执行失败 */ public function event($event, $ip, $username, $password = "") { $len = 0; if (!parent::pack_write_u8(IPCService::WTM_IPC_VERSION)) { return FALSE; } if (!parent::pack_write_u8(IPCService::WTM_COMM_SYNC_USERINFO)) { return FALSE; } $len = strlen($username); if (!parent::pack_write_u32($len)) { return FALSE; } if ($len > 0) { if (!parent::pack_write($username, $len)) { return FALSE; } } $len = strlen($password); if (!parent::pack_write_u32($len)) { return FALSE; } if ($len > 0) { if (!parent::pack_write($password, $len)) { return FALSE; } } if (!parent::pack_write_u32(ip2long($ip))) { return FALSE; } if ($event == "login") { $e = 0; } else { if ($event == "logout") { $e = 1; } else { if ($event == "update") { $e = 2; } else { return FALSE; } } } if (!parent::pack_write_u8($e)) { return FALSE; } if (parent::read_unpack_u8() != IPCService::WTM_IPC_VERSION) { return FALSE; } if (parent::read_unpack_u8() != IPCService::WTM_COMM_SYNC_USERINFO) { return FALSE; } return parent::read_unpack_u8(); }
public function query() { if (!parent::pack_write_u8(IPCService::WTM_IPC_VERSION)) { return FALSE; } if (!parent::pack_write_u8(IPCService::WTM_COMM_REALTIME_STAT_QUERY)) { return FALSE; } if (!parent::pack_write_u8(IPCService::WTM_RTS_OVERVIEW_QUERY)) { return FALSE; } if (parent::read_unpack_u8() != IPCService::WTM_IPC_VERSION) { return FALSE; } if (parent::read_unpack_u8() != IPCService::WTM_COMM_REALTIME_STAT_REPLY) { return FALSE; } if (parent::read_unpack_u8() != IPCService::WTM_RTS_OVERVIEW_REPLY) { return FALSE; } $count = parent::read_unpack_u32(); if ($count === FALSE) { return FALSE; } for ($i = 0; $i < $count; $i++) { $attribute_type = parent::read_unpack_u16(); if ($this->attributes_length[$attribute_type] == 1) { $this->attributes[$attribute_type] = parent::read_unpack_u8(); } else { if ($this->attributes_length[$attribute_type] == 2) { $this->attributes[$attribute_type] = parent::read_unpack_u16(); } else { if ($this->attributes_length[$attribute_type] == 4) { $this->attributes[$attribute_type] = parent::read_unpack_u32(); } else { if ($this->attributes_length[$attribute_type] == 8) { $this->attributes[$attribute_type] = parent::read_unpack_u64(); } } } } } return $this->attributes; }