Skip to content

Commit d491575

Browse files
committed
Implemente sendChatMessage API
1 parent 35cf08c commit d491575

8 files changed

Lines changed: 245 additions & 0 deletions

File tree

src/BigBlueButton.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
use BigBlueButton\Parameters\JoinMeetingParameters;
3636
use BigBlueButton\Parameters\PublishRecordingsParameters;
3737
use BigBlueButton\Parameters\PutRecordingTextTrackParameters;
38+
use BigBlueButton\Parameters\SendChatMessageParameters;
3839
use BigBlueButton\Parameters\UpdateRecordingsParameters;
3940
use BigBlueButton\Responses\ApiVersionResponse;
4041
use BigBlueButton\Responses\CreateMeetingResponse;
@@ -52,6 +53,7 @@
5253
use BigBlueButton\Responses\JoinMeetingResponse;
5354
use BigBlueButton\Responses\PublishRecordingsResponse;
5455
use BigBlueButton\Responses\PutRecordingTextTrackResponse;
56+
use BigBlueButton\Responses\SendChatMessageResponse;
5557
use BigBlueButton\Responses\UpdateRecordingsResponse;
5658
use BigBlueButton\Util\UrlBuilder;
5759

@@ -138,6 +140,7 @@ public function getApiVersion(): ApiVersionResponse
138140
-- join
139141
-- end
140142
-- insertDocument
143+
-- sendChatMessage
141144
*/
142145

143146
/**
@@ -212,6 +215,13 @@ public function insertDocument(InsertDocumentParameters $insertDocumentParams):
212215
return new InsertDocumentResponse($xml);
213216
}
214217

218+
public function sendChatMessage(SendChatMessageParameters $sendChatMessageParams): SendChatMessageResponse
219+
{
220+
$xml = $this->processXmlResponse($this->getUrlBuilder()->getSendChatMessageUrl($sendChatMessageParams));
221+
222+
return new SendChatMessageResponse($xml);
223+
}
224+
215225
// __________________ BBB MONITORING METHODS _________________
216226
/* The methods in the following section support the following categories of the BBB API:
217227
-- isMeetingRunning
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
3+
/*
4+
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
5+
*
6+
* Copyright (c) 2016-2025 BigBlueButton Inc. and by respective authors (see below).
7+
*
8+
* This program is free software; you can redistribute it and/or modify it under the
9+
* terms of the GNU Lesser General Public License as published by the Free Software
10+
* Foundation; either version 3.0 of the License, or (at your option) any later
11+
* version.
12+
*
13+
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
14+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15+
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public License along
18+
* with BigBlueButton; if not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
namespace BigBlueButton\Parameters;
22+
23+
use BigBlueButton\Attribute\ApiParameterMapper;
24+
25+
/**
26+
* Class SendChatMessageParameters.
27+
*/
28+
class SendChatMessageParameters extends MetaParameters
29+
{
30+
private string $meetingId;
31+
32+
private string $message;
33+
34+
private ?string $userName = null;
35+
36+
/**
37+
* CreateMeetingParameters constructor.
38+
*/
39+
public function __construct(string $meetingId, string $message)
40+
{
41+
$this->meetingId = $meetingId;
42+
$this->message = $message;
43+
}
44+
45+
#[ApiParameterMapper(attributeName: 'meetingID')]
46+
public function getMeetingId(): string
47+
{
48+
return $this->meetingId;
49+
}
50+
51+
public function setMeetingId(string $meetingId): self
52+
{
53+
$this->meetingId = $meetingId;
54+
55+
return $this;
56+
}
57+
58+
#[ApiParameterMapper(attributeName: 'message')]
59+
public function getMessage(): string
60+
{
61+
return $this->message;
62+
}
63+
64+
public function setMessage(string $message): self
65+
{
66+
$this->message = $message;
67+
68+
return $this;
69+
}
70+
71+
#[ApiParameterMapper(attributeName: 'userName')]
72+
public function getUserName(): ?string
73+
{
74+
return $this->userName;
75+
}
76+
77+
public function setUserName(string $userName): self
78+
{
79+
$this->userName = $userName;
80+
81+
return $this;
82+
}
83+
84+
public function getHTTPQuery(): string
85+
{
86+
$queries = $this->toApiDataArray();
87+
$queries = $this->buildMeta($queries);
88+
89+
return $this->buildHTTPQuery($queries);
90+
}
91+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
/*
4+
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
5+
*
6+
* Copyright (c) 2016-2025 BigBlueButton Inc. and by respective authors (see below).
7+
*
8+
* This program is free software; you can redistribute it and/or modify it under the
9+
* terms of the GNU Lesser General Public License as published by the Free Software
10+
* Foundation; either version 3.0 of the License, or (at your option) any later
11+
* version.
12+
*
13+
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
14+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15+
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public License along
18+
* with BigBlueButton; if not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
namespace BigBlueButton\Responses;
22+
23+
/**
24+
* Class PublishRecordingsResponse.
25+
*/
26+
class SendChatMessageResponse extends BaseResponse {}

src/Util/UrlBuilder.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
use BigBlueButton\Parameters\JoinMeetingParameters;
3636
use BigBlueButton\Parameters\PublishRecordingsParameters;
3737
use BigBlueButton\Parameters\PutRecordingTextTrackParameters;
38+
use BigBlueButton\Parameters\SendChatMessageParameters;
3839
use BigBlueButton\Parameters\UpdateRecordingsParameters;
3940

4041
class UrlBuilder
@@ -126,6 +127,11 @@ public function getInsertDocumentUrl(InsertDocumentParameters $insertDocumentPar
126127
return $this->buildUrl(ApiMethod::INSERT_DOCUMENT, $insertDocumentParameters->getHTTPQuery());
127128
}
128129

130+
public function getSendChatMessageUrl(SendChatMessageParameters $sendChatMessageParameters): string
131+
{
132+
return $this->buildUrl(ApiMethod::SEND_CHAT_MESSAGE, $sendChatMessageParameters->getHTTPQuery());
133+
}
134+
129135
public function getIsMeetingRunningUrl(IsMeetingRunningParameters $meetingParams): string
130136
{
131137
return $this->buildUrl(ApiMethod::IS_MEETING_RUNNING, $meetingParams->getHTTPQuery());

tests/BigBlueButtonTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
use BigBlueButton\Parameters\InsertDocumentParameters;
3535
use BigBlueButton\Parameters\IsMeetingRunningParameters;
3636
use BigBlueButton\Parameters\PublishRecordingsParameters;
37+
use BigBlueButton\Parameters\SendChatMessageParameters;
3738
use BigBlueButton\TestServices\EnvLoader;
3839
use BigBlueButton\TestServices\Fixtures;
3940
use BigBlueButton\TestServices\ParamsIterator;
@@ -353,6 +354,18 @@ public function testInsertDocumentUrlAndFile(): void
353354
}
354355
}
355356

357+
public function testSendChatMessage(): void
358+
{
359+
$createMeetingParameters = Fixtures::getCreateMeetingParametersMock(Fixtures::generateCreateParams());
360+
$createMeetingResponse = $this->bbb->createMeeting($createMeetingParameters);
361+
362+
$sendChatMessageParameters = new SendChatMessageParameters($createMeetingResponse->getMeetingId(), $this->faker->sentence());
363+
$sendChatMessageParameters->setUserName($this->faker->userName());
364+
$sendChatMessageResponse = $this->bbb->sendChatMessage($sendChatMessageParameters);
365+
366+
$this->assertTrue($sendChatMessageResponse->success());
367+
}
368+
356369
// Join Meeting
357370

358371
/**
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
/*
4+
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
5+
*
6+
* Copyright (c) 2016-2025 BigBlueButton Inc. and by respective authors (see below).
7+
*
8+
* This program is free software; you can redistribute it and/or modify it under the
9+
* terms of the GNU Lesser General Public License as published by the Free Software
10+
* Foundation; either version 3.0 of the License, or (at your option) any later
11+
* version.
12+
*
13+
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
14+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15+
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public License along
18+
* with BigBlueButton; if not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
namespace BigBlueButton\Parameters;
22+
23+
/**
24+
* @internal
25+
*/
26+
class SendChatMessageParametersTest extends ParameterTestCase
27+
{
28+
public function testEndMeetingParameters(): void
29+
{
30+
$sendChatMessageParams = new SendChatMessageParameters($meetingId = $this->faker->uuid(), $message = $this->faker->sentence());
31+
32+
$this->assertEquals($meetingId, $sendChatMessageParams->getMeetingId());
33+
$this->assertEquals($message, $sendChatMessageParams->getMessage());
34+
35+
// Test setters that are ignored by the constructor
36+
$sendChatMessageParams->setMeetingId($newId = $this->faker->uuid);
37+
$sendChatMessageParams->setMessage($newMessage = $this->faker->sentence);
38+
$this->assertEquals($newId, $sendChatMessageParams->getMeetingId());
39+
$this->assertEquals($newMessage, $sendChatMessageParams->getMessage());
40+
}
41+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
/*
4+
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
5+
*
6+
* Copyright (c) 2016-2025 BigBlueButton Inc. and by respective authors (see below).
7+
*
8+
* This program is free software; you can redistribute it and/or modify it under the
9+
* terms of the GNU Lesser General Public License as published by the Free Software
10+
* Foundation; either version 3.0 of the License, or (at your option) any later
11+
* version.
12+
*
13+
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
14+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15+
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public License along
18+
* with BigBlueButton; if not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
namespace BigBlueButton\Responses;
22+
23+
use BigBlueButton\TestCase;
24+
use BigBlueButton\TestServices\Fixtures;
25+
26+
/**
27+
* @internal
28+
*/
29+
class SendChatMessageResponseTest extends TestCase
30+
{
31+
private SendChatMessageResponse $sendChatMessage;
32+
33+
public function setUp(): void
34+
{
35+
parent::setUp();
36+
$fixtures = new Fixtures();
37+
38+
$xml = $fixtures->fromXmlFile('send_chat_message.xml');
39+
40+
$this->sendChatMessage = new SendChatMessageResponse($xml);
41+
}
42+
43+
public function testPublishRecordingsResponseContent(): void
44+
{
45+
$this->assertEquals('SUCCESS', $this->sendChatMessage->getReturnCode());
46+
$this->assertEquals('documentInserted', $this->sendChatMessage->getMessageKey());
47+
}
48+
49+
public function testPublishRecordingsResponseTypes(): void
50+
{
51+
$this->assertEachGetterValueIsString($this->sendChatMessage, ['getReturnCode', 'getMessageKey']);
52+
}
53+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<response>
2+
<returncode>SUCCESS</returncode>
3+
<messageKey>documentInserted</messageKey>
4+
<message>Presentation is being uploaded</message>
5+
</response>

0 commit comments

Comments
 (0)