Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit b6be373

Browse files
authored
Merge pull request #18 from swooletw/develop
Develop
2 parents 8ab430c + a61d09e commit b6be373

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

routes/websocket.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
use Illuminate\Http\Request
3+
use Illuminate\Http\Request;
44
use SwooleTW\Http\Websocket\Facades\Websocket;
55

66
/*

src/Websocket/CanWebsocket.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function onClose(Server $server, $fd, $reactorId)
119119

120120
try {
121121
// leave all rooms
122-
$this->websocket->reset(true)->setSender($fd)->leaveAll();
122+
$this->websocket->reset(true)->setSender($fd)->leave();
123123
// trigger 'disconnect' websocket event
124124
if ($this->websocket->eventExists('disconnect')) {
125125
$this->websocket->call('disconnect');

src/Websocket/Websocket.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function join($rooms)
116116
{
117117
$rooms = is_string($rooms) || is_integer($rooms) ? func_get_args() : $rooms;
118118

119-
$this->room->addAll($this->sender, $rooms);
119+
$this->room->add($this->sender, $rooms);
120120

121121
return $this;
122122
}
@@ -126,11 +126,11 @@ public function join($rooms)
126126
*
127127
* @param string, array
128128
*/
129-
public function leave($rooms)
129+
public function leave($rooms = [])
130130
{
131131
$rooms = is_string($rooms) || is_integer($rooms) ? func_get_args() : $rooms;
132132

133-
$this->room->deleteAll($this->sender, $rooms);
133+
$this->room->delete($this->sender, $rooms);
134134

135135
return $this;
136136
}
@@ -175,7 +175,7 @@ public function emit(string $event, $data)
175175
*
176176
* @param string
177177
*/
178-
public function in(string $room)
178+
public function in($room)
179179
{
180180
$this->join($room);
181181

tests/Websocket/WebsocketTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testSetSender()
4040
public function testJoin()
4141
{
4242
$room = m::mock(RoomContract::class);
43-
$room->shouldReceive('addAll')
43+
$room->shouldReceive('add')
4444
->with($sender = 1, $name = ['room'])
4545
->once();
4646

@@ -52,7 +52,7 @@ public function testJoin()
5252
public function testJoinAll()
5353
{
5454
$room = m::mock(RoomContract::class);
55-
$room->shouldReceive('addAll')
55+
$room->shouldReceive('add')
5656
->with($sender = 1, $names = ['room1', 'room2'])
5757
->once();
5858

@@ -64,7 +64,7 @@ public function testJoinAll()
6464
public function testLeave()
6565
{
6666
$room = m::mock(RoomContract::class);
67-
$room->shouldReceive('deleteAll')
67+
$room->shouldReceive('delete')
6868
->with($sender = 1, $name = ['room'])
6969
->once();
7070

@@ -76,7 +76,7 @@ public function testLeave()
7676
public function testLeaveAll()
7777
{
7878
$room = m::mock(RoomContract::class);
79-
$room->shouldReceive('deleteAll')
79+
$room->shouldReceive('delete')
8080
->with($sender = 1, $names = ['room1', 'room2'])
8181
->once();
8282

@@ -108,7 +108,7 @@ public function testLoginUsing()
108108
->andReturn($id = 1);
109109

110110
$room = m::mock(RoomContract::class);
111-
$room->shouldReceive('addAll')
111+
$room->shouldReceive('add')
112112
->with($sender = 1, ['uid_1'])
113113
->once();
114114

@@ -120,7 +120,7 @@ public function testLoginUsing()
120120
public function testLoginUsingId()
121121
{
122122
$room = m::mock(RoomContract::class);
123-
$room->shouldReceive('addAll')
123+
$room->shouldReceive('add')
124124
->with($sender = 1, ['uid_1'])
125125
->once();
126126

0 commit comments

Comments
 (0)