Broadcast both locally and across servers on dashboard logger.

This commit is contained in:
Alex Renoki 2020-09-18 20:27:12 +03:00
parent 7519da4a08
commit 546c4fd0ef
2 changed files with 18 additions and 8 deletions

View File

@ -136,6 +136,18 @@ class Channel
return true; return true;
} }
/**
* Broadcast a payload to the locally-subscribed connections.
*
* @param string|int $appId
* @param \stdClass $payload
* @return bool
*/
public function broadcastLocally($appId, stdClass $payload): bool
{
return $this->broadcast($appId, $payload, false);
}
/** /**
* Broadcast the payload, but exclude a specific socket id. * Broadcast the payload, but exclude a specific socket id.
* *

View File

@ -83,15 +83,13 @@ class DashboardLogger
$channel = $channelManager->find($appId, $channelName); $channel = $channelManager->find($appId, $channelName);
if ($channel) { if ($channel) {
$channel->broadcastToEveryoneExcept( $channel->broadcastLocally(
(object) $payload, $appId, (object) $payload, true
null,
$appId
);
} else {
$channelManager->broadcastAcrossServers(
$appId, null, $channelName, (object) $payload
); );
} }
$channelManager->broadcastAcrossServers(
$appId, null, $channelName, (object) $payload
);
} }
} }