Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.buildpath
.project
.settings
.idea
.idea
vendor
.vscode
composer.lock
15 changes: 15 additions & 0 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,21 @@ public function onWorkerMessage($connection, $data)
} else {
$buffer = serialize(array_keys($this->_uidConnections[$uid]));
}
$connection->send(pack('N', strlen($buffer)) . $buffer, true);
return;
// 批量获取与 uid 绑定的所有 client_id Gateway::batchGetClientIdByUid($uid);
case GatewayProtocol::CMD_BATCH_GET_CLIENT_ID_BY_UID:
$uids = json_decode($data['ext_data']);
$return = [];
foreach ($uids as $uid) {
if (empty($this->_uidConnections[$uid])) {
$return[$uid] = [];
} else {
$return[$uid] = array_keys($this->_uidConnections[$uid]);
}
}
$buffer = serialize($return);

$connection->send(pack('N', strlen($buffer)) . $buffer, true);
return;
default :
Expand Down
3 changes: 3 additions & 0 deletions src/Protocols/GatewayProtocol.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ class GatewayProtocol
// 根据uid获取绑定的clientid
const CMD_GET_CLIENT_ID_BY_UID = 15;

// 批量获取uid列表批量获取绑定的clientid
const CMD_BATCH_GET_CLIENT_ID_BY_UID = 16;

// 加入组
const CMD_JOIN_GROUP = 20;

Expand Down