8000 Add batch api method by everlCode · Pull Request #67 · centrifugal/phpcent · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add batch api method #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 16, 2024
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
11 changes: 11 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,17 @@ public function info()
return $this->send('info');
}

/**
* Sending many commands in one request
*
* @param array $data
* @return mixed
*/
public function batch(array $data)
{
return $this->send('batch', $data);
}

/**
* Generate connection JWT. See https://centrifugal.dev/docs/server/authentication.
* Keep in mind that this method does not support all claims of Centrifugo JWT connection
Expand Down
28 changes: 27 additions & 1 deletion tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ public function testPublishNetworkError()
{
$this->expectException(Exception::class);
$client = new \phpcent\Client("http://localhost:9000/api");
$res = $client->publish('channel', ["message" => "Hello World"]);

$client->setConnectTimeoutOption(5);
$client->setTimeoutOption(15);

$client->publish('channel', ["message" => "Hello World"]);
}

public function testInfo()
Expand All @@ -77,4 +81,26 @@ public function testInfo()
$this->assertNotNull($res);
$this->assertTrue(is_array($res->result->nodes));
}

public function testBatch()
{
$data = [
"commands" => [
[
"presence_stats" => [
"channel" => "test1"
]
],
[
"publish" => [
"channel" => "x:test2",
"data" => []
]
]
]
];

$res = $this->client->batch($data);
$this->assertIsArray($res->replies);
}
}
Loading
0