Replaced __call with direct function call
This commit is contained in:
parent
c078e5a2b7
commit
bd3aa90b65
|
|
@ -104,7 +104,7 @@ class RedisClient extends LocalClient
|
||||||
|
|
||||||
$payload = json_encode($payload);
|
$payload = json_encode($payload);
|
||||||
|
|
||||||
$this->publishClient->__call('publish', [$this->getTopicName($appId, $channel), $payload]);
|
$this->publishClient->publish($this->getTopicName($appId, $channel), $payload);
|
||||||
|
|
||||||
DashboardLogger::log($appId, DashboardLogger::TYPE_REPLICATOR_MESSAGE_PUBLISHED, [
|
DashboardLogger::log($appId, DashboardLogger::TYPE_REPLICATOR_MESSAGE_PUBLISHED, [
|
||||||
'channel' => $channel,
|
'channel' => $channel,
|
||||||
|
|
@ -127,7 +127,7 @@ class RedisClient extends LocalClient
|
||||||
{
|
{
|
||||||
if (! isset($this->subscribedChannels["{$appId}:{$channel}"])) {
|
if (! isset($this->subscribedChannels["{$appId}:{$channel}"])) {
|
||||||
// We're not subscribed to the channel yet, subscribe and set the count to 1
|
// We're not subscribed to the channel yet, subscribe and set the count to 1
|
||||||
$this->subscribeClient->__call('subscribe', [$this->getTopicName($appId, $channel)]);
|
$this->subscribeClient->subscribe($this->getTopicName($appId, $channel));
|
||||||
$this->subscribedChannels["{$appId}:{$channel}"] = 1;
|
$this->subscribedChannels["{$appId}:{$channel}"] = 1;
|
||||||
} else {
|
} else {
|
||||||
// Increment the subscribe count if we've already subscribed
|
// Increment the subscribe count if we've already subscribed
|
||||||
|
|
@ -161,7 +161,7 @@ class RedisClient extends LocalClient
|
||||||
|
|
||||||
// If we no longer have subscriptions to that channel, unsubscribe
|
// If we no longer have subscriptions to that channel, unsubscribe
|
||||||
if ($this->subscribedChannels["{$appId}:{$channel}"] < 1) {
|
if ($this->subscribedChannels["{$appId}:{$channel}"] < 1) {
|
||||||
$this->subscribeClient->__call('unsubscribe', [$this->getTopicName($appId, $channel)]);
|
$this->subscribeClient->unsubscribe($this->getTopicName($appId, $channel));
|
||||||
|
|
||||||
unset($this->subscribedChannels["{$appId}:{$channel}"]);
|
unset($this->subscribedChannels["{$appId}:{$channel}"]);
|
||||||
}
|
}
|
||||||
|
|
@ -183,9 +183,9 @@ class RedisClient extends LocalClient
|
||||||
*/
|
*/
|
||||||
public function subscribeToApp($appId): bool
|
public function subscribeToApp($appId): bool
|
||||||
{
|
{
|
||||||
$this->subscribeClient->__call('subscribe', [$this->getTopicName($appId)]);
|
$this->subscribeClient->subscribe($this->getTopicName($appId));
|
||||||
|
|
||||||
$this->publishClient->__call('hincrby', [$this->getTopicName($appId), 'connections', 1]);
|
$this->publishClient->hincrby($this->getTopicName($appId), 'connections', 1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -198,9 +198,9 @@ class RedisClient extends LocalClient
|
||||||
*/
|
*/
|
||||||
public function unsubscribeFromApp($appId): bool
|
public function unsubscribeFromApp($appId): bool
|
||||||
{
|
{
|
||||||
$this->subscribeClient->__call('unsubscribe', [$this->getTopicName($appId)]);
|
$this->subscribeClient->unsubscribe($this->getTopicName($appId));
|
||||||
|
|
||||||
$this->publishClient->__call('hincrby', [$this->getTopicName($appId), 'connections', -1]);
|
$this->publishClient->hincrby($this->getTopicName($appId), 'connections', -1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -217,7 +217,7 @@ class RedisClient extends LocalClient
|
||||||
*/
|
*/
|
||||||
public function joinChannel($appId, string $channel, string $socketId, string $data)
|
public function joinChannel($appId, string $channel, string $socketId, string $data)
|
||||||
{
|
{
|
||||||
$this->publishClient->__call('hset', [$this->getTopicName($appId, $channel), $socketId, $data]);
|
$this->publishClient->hset($this->getTopicName($appId, $channel), $socketId, $data);
|
||||||
|
|
||||||
DashboardLogger::log($appId, DashboardLogger::TYPE_REPLICATOR_JOINED_CHANNEL, [
|
DashboardLogger::log($appId, DashboardLogger::TYPE_REPLICATOR_JOINED_CHANNEL, [
|
||||||
'channel' => $channel,
|
'channel' => $channel,
|
||||||
|
|
@ -239,7 +239,7 @@ class RedisClient extends LocalClient
|
||||||
*/
|
*/
|
||||||
public function leaveChannel($appId, string $channel, string $socketId)
|
public function leaveChannel($appId, string $channel, string $socketId)
|
||||||
{
|
{
|
||||||
$this->publishClient->__call('hdel', [$this->getTopicName($appId, $channel), $socketId]);
|
$this->publishClient->hdel($this->getTopicName($appId, $channel), $socketId);
|
||||||
|
|
||||||
DashboardLogger::log($appId, DashboardLogger::TYPE_REPLICATOR_LEFT_CHANNEL, [
|
DashboardLogger::log($appId, DashboardLogger::TYPE_REPLICATOR_LEFT_CHANNEL, [
|
||||||
'channel' => $channel,
|
'channel' => $channel,
|
||||||
|
|
@ -258,7 +258,7 @@ class RedisClient extends LocalClient
|
||||||
*/
|
*/
|
||||||
public function channelMembers($appId, string $channel): PromiseInterface
|
public function channelMembers($appId, string $channel): PromiseInterface
|
||||||
{
|
{
|
||||||
return $this->publishClient->__call('hgetall', [$this->getTopicName($appId, $channel)])
|
return $this->publishClient->hgetall($this->getTopicName($appId, $channel))
|
||||||
->then(function ($members) {
|
->then(function ($members) {
|
||||||
// The data is expected as objects, so we need to JSON decode
|
// The data is expected as objects, so we need to JSON decode
|
||||||
return array_map(function ($user) {
|
return array_map(function ($user) {
|
||||||
|
|
@ -279,7 +279,7 @@ class RedisClient extends LocalClient
|
||||||
$this->publishClient->__call('multi', []);
|
$this->publishClient->__call('multi', []);
|
||||||
|
|
||||||
foreach ($channelNames as $channel) {
|
foreach ($channelNames as $channel) {
|
||||||
$this->publishClient->__call('hlen', [$this->getTopicName($appId, $channel)]);
|
$this->publishClient->hlen($this->getTopicName($appId, $channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->publishClient->__call('exec', [])
|
return $this->publishClient->__call('exec', [])
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ class RedisStatisticsLogger implements StatisticsLogger
|
||||||
public function webSocketMessage($appId)
|
public function webSocketMessage($appId)
|
||||||
{
|
{
|
||||||
$this->ensureAppIsSet($appId)
|
$this->ensureAppIsSet($appId)
|
||||||
->__call('hincrby', [$this->getHash($appId), 'websocket_message_count', 1]);
|
->hincrby($this->getHash($appId), 'websocket_message_count', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -71,7 +71,7 @@ class RedisStatisticsLogger implements StatisticsLogger
|
||||||
public function apiMessage($appId)
|
public function apiMessage($appId)
|
||||||
{
|
{
|
||||||
$this->ensureAppIsSet($appId)
|
$this->ensureAppIsSet($appId)
|
||||||
->__call('hincrby', [$this->getHash($appId), 'api_message_count', 1]);
|
->hincrby($this->getHash($appId), 'api_message_count', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -84,13 +84,13 @@ class RedisStatisticsLogger implements StatisticsLogger
|
||||||
{
|
{
|
||||||
// Increment the current connections count by 1.
|
// Increment the current connections count by 1.
|
||||||
$incremented = $this->ensureAppIsSet($appId)
|
$incremented = $this->ensureAppIsSet($appId)
|
||||||
->__call('hincrby', [$this->getHash($appId), 'current_connection_count', 1]);
|
->hincrby($this->getHash($appId), 'current_connection_count', 1);
|
||||||
|
|
||||||
$incremented->then(function ($currentConnectionCount) use ($appId) {
|
$incremented->then(function ($currentConnectionCount) use ($appId) {
|
||||||
// Get the peak connections count from Redis.
|
// Get the peak connections count from Redis.
|
||||||
$peakConnectionCount = $this->replicator
|
$peakConnectionCount = $this->replicator
|
||||||
->getPublishClient()
|
->getPublishClient()
|
||||||
->__call('hget', [$this->getHash($appId), 'peak_connection_count']);
|
->hget($this->getHash($appId), 'peak_connection_count');
|
||||||
|
|
||||||
$peakConnectionCount->then(function ($currentPeakConnectionCount) use ($currentConnectionCount, $appId) {
|
$peakConnectionCount->then(function ($currentPeakConnectionCount) use ($currentConnectionCount, $appId) {
|
||||||
// Extract the greatest number between the current peak connection count
|
// Extract the greatest number between the current peak connection count
|
||||||
|
|
@ -103,7 +103,7 @@ class RedisStatisticsLogger implements StatisticsLogger
|
||||||
// Then set it to the database.
|
// Then set it to the database.
|
||||||
$this->replicator
|
$this->replicator
|
||||||
->getPublishClient()
|
->getPublishClient()
|
||||||
->__call('hset', [$this->getHash($appId), 'peak_connection_count', $peakConnectionCount]);
|
->hset($this->getHash($appId), 'peak_connection_count', $peakConnectionCount);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -118,13 +118,13 @@ class RedisStatisticsLogger implements StatisticsLogger
|
||||||
{
|
{
|
||||||
// Decrement the current connections count by 1.
|
// Decrement the current connections count by 1.
|
||||||
$decremented = $this->ensureAppIsSet($appId)
|
$decremented = $this->ensureAppIsSet($appId)
|
||||||
->__call('hincrby', [$this->getHash($appId), 'current_connection_count', -1]);
|
->hincrby($this->getHash($appId), 'current_connection_count', -1);
|
||||||
|
|
||||||
$decremented->then(function ($currentConnectionCount) use ($appId) {
|
$decremented->then(function ($currentConnectionCount) use ($appId) {
|
||||||
// Get the peak connections count from Redis.
|
// Get the peak connections count from Redis.
|
||||||
$peakConnectionCount = $this->replicator
|
$peakConnectionCount = $this->replicator
|
||||||
->getPublishClient()
|
->getPublishClient()
|
||||||
->__call('hget', [$this->getHash($appId), 'peak_connection_count']);
|
->hget($this->getHash($appId), 'peak_connection_count');
|
||||||
|
|
||||||
$peakConnectionCount->then(function ($currentPeakConnectionCount) use ($currentConnectionCount, $appId) {
|
$peakConnectionCount->then(function ($currentPeakConnectionCount) use ($currentConnectionCount, $appId) {
|
||||||
// Extract the greatest number between the current peak connection count
|
// Extract the greatest number between the current peak connection count
|
||||||
|
|
@ -137,7 +137,7 @@ class RedisStatisticsLogger implements StatisticsLogger
|
||||||
// Then set it to the database.
|
// Then set it to the database.
|
||||||
$this->replicator
|
$this->replicator
|
||||||
->getPublishClient()
|
->getPublishClient()
|
||||||
->__call('hset', [$this->getHash($appId), 'peak_connection_count', $peakConnectionCount]);
|
->hset($this->getHash($appId), 'peak_connection_count', $peakConnectionCount);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -152,13 +152,13 @@ class RedisStatisticsLogger implements StatisticsLogger
|
||||||
$this->lock()->get(function () {
|
$this->lock()->get(function () {
|
||||||
$setMembers = $this->replicator
|
$setMembers = $this->replicator
|
||||||
->getPublishClient()
|
->getPublishClient()
|
||||||
->__call('smembers', ['laravel-websockets:apps']);
|
->smembers('laravel-websockets:apps');
|
||||||
|
|
||||||
$setMembers->then(function ($members) {
|
$setMembers->then(function ($members) {
|
||||||
foreach ($members as $appId) {
|
foreach ($members as $appId) {
|
||||||
$member = $this->replicator
|
$member = $this->replicator
|
||||||
->getPublishClient()
|
->getPublishClient()
|
||||||
->__call('hgetall', [$this->getHash($appId)]);
|
->hgetall($this->getHash($appId));
|
||||||
|
|
||||||
$member->then(function ($statistic) use ($appId) {
|
$member->then(function ($statistic) use ($appId) {
|
||||||
if (! $statistic) {
|
if (! $statistic) {
|
||||||
|
|
@ -201,7 +201,7 @@ class RedisStatisticsLogger implements StatisticsLogger
|
||||||
{
|
{
|
||||||
$this->replicator
|
$this->replicator
|
||||||
->getPublishClient()
|
->getPublishClient()
|
||||||
->__call('sadd', ['laravel-websockets:apps', $appId]);
|
->sadd('laravel-websockets:apps', $appId);
|
||||||
|
|
||||||
return $this->replicator->getPublishClient();
|
return $this->replicator->getPublishClient();
|
||||||
}
|
}
|
||||||
|
|
@ -217,19 +217,19 @@ class RedisStatisticsLogger implements StatisticsLogger
|
||||||
{
|
{
|
||||||
$this->replicator
|
$this->replicator
|
||||||
->getPublishClient()
|
->getPublishClient()
|
||||||
->__call('hset', [$this->getHash($appId), 'current_connection_count', $currentConnectionCount]);
|
->hset($this->getHash($appId), 'current_connection_count', $currentConnectionCount);
|
||||||
|
|
||||||
$this->replicator
|
$this->replicator
|
||||||
->getPublishClient()
|
->getPublishClient()
|
||||||
->__call('hset', [$this->getHash($appId), 'peak_connection_count', $currentConnectionCount]);
|
->hset($this->getHash($appId), 'peak_connection_count', $currentConnectionCount);
|
||||||
|
|
||||||
$this->replicator
|
$this->replicator
|
||||||
->getPublishClient()
|
->getPublishClient()
|
||||||
->__call('hset', [$this->getHash($appId), 'websocket_message_count', 0]);
|
->hset($this->getHash($appId), 'websocket_message_count', 0);
|
||||||
|
|
||||||
$this->replicator
|
$this->replicator
|
||||||
->getPublishClient()
|
->getPublishClient()
|
||||||
->__call('hset', [$this->getHash($appId), 'api_message_count', 0]);
|
->hset($this->getHash($appId), 'api_message_count', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -243,23 +243,23 @@ class RedisStatisticsLogger implements StatisticsLogger
|
||||||
{
|
{
|
||||||
$this->replicator
|
$this->replicator
|
||||||
->getPublishClient()
|
->getPublishClient()
|
||||||
->__call('hdel', [$this->getHash($appId), 'current_connection_count']);
|
->hdel($this->getHash($appId), 'current_connection_count');
|
||||||
|
|
||||||
$this->replicator
|
$this->replicator
|
||||||
->getPublishClient()
|
->getPublishClient()
|
||||||
->__call('hdel', [$this->getHash($appId), 'peak_connection_count']);
|
->hdel($this->getHash($appId), 'peak_connection_count');
|
||||||
|
|
||||||
$this->replicator
|
$this->replicator
|
||||||
->getPublishClient()
|
->getPublishClient()
|
||||||
->__call('hdel', [$this->getHash($appId), 'websocket_message_count']);
|
->hdel($this->getHash($appId), 'websocket_message_count');
|
||||||
|
|
||||||
$this->replicator
|
$this->replicator
|
||||||
->getPublishClient()
|
->getPublishClient()
|
||||||
->__call('hdel', [$this->getHash($appId), 'api_message_count']);
|
->hdel($this->getHash($appId), 'api_message_count');
|
||||||
|
|
||||||
$this->replicator
|
$this->replicator
|
||||||
->getPublishClient()
|
->getPublishClient()
|
||||||
->__call('srem', ['laravel-websockets:apps', $appId]);
|
->srem('laravel-websockets:apps', $appId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue