Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

update socket.io version and fixbug #614

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ file, the following options can be overridden:
- `databaseConfig.redis.host`: `LARAVEL_ECHO_SERVER_REDIS_HOST`
- `databaseConfig.redis.port`: `LARAVEL_ECHO_SERVER_REDIS_PORT`
- `databaseConfig.redis.password`: `LARAVEL_ECHO_SERVER_REDIS_PASSWORD`
- `databaseConfig.redis.db`: `LARAVEL_ECHO_SERVER_REDIS_DB`
- `databaseConfig.redis.prefix`: `LARAVEL_ECHO_SERVER_REDIS_PREFIX`
- `protocol`: `LARAVEL_ECHO_SERVER_PROTO`
- `sslKeyPath`: `LARAVEL_ECHO_SERVER_SSL_KEY`
- `sslCertPath`: `LARAVEL_ECHO_SERVER_SSL_CERT`
Expand Down
759 changes: 255 additions & 504 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"dotenv": "^8.2.0",
"express": "^4.17.1",
"inquirer": "^7.1.0",
"ioredis": "^4.16.0",
"ioredis": "^5.3.2",
"lodash": "^4.17.15",
"request": "^2.88.2",
"socket.io": "^2.3.0",
"socket.io": "^4.7.1",
"yargs": "^15.3.1"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/channels/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class Channel {
if (this.isClientEvent(data.event) &&
this.isPrivate(data.channel) &&
this.isInChannel(socket, data.channel)) {
this.io.sockets.connected[socket.id]
this.io.sockets.sockets.get(socket.id)
.broadcast.to(data.channel)
.emit(data.event, data.channel, data.data);
}
Expand Down Expand Up @@ -109,7 +109,7 @@ export class Channel {
socket.join(data.channel);

if (this.isPresence(data.channel)) {
var member = res.channel_data;
let member = res.channel_data;
try {
member = JSON.parse(res.channel_data);
} catch (e) { }
Expand Down
11 changes: 6 additions & 5 deletions src/channels/presence-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,17 @@ export class PresenceChannel {
this.io
.of("/")
.in(channel)
.clients((error, clients) => {
.allSockets()
.then((clients) => {
members = members || [];
members = members.filter((member) => {
return clients.indexOf(member.socketId) >= 0;
return clients.has(member.socketId);
});

this.db.set(channel + ":members", members);

resolve(members);
});
})
});
}

Expand Down Expand Up @@ -141,8 +142,8 @@ export class PresenceChannel {
* On join event handler.
*/
onJoin(socket: any, channel: string, member: any): void {
this.io.sockets.connected[socket.id].broadcast
.to(channel)
this.io.sockets.sockets.get(socket.id)
.broadcast.to(channel)
.emit("presence:joining", channel, member);
}

Expand Down
2 changes: 2 additions & 0 deletions src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export class Cli {
LARAVEL_ECHO_SERVER_REDIS_HOST: "databaseConfig.redis.host",
LARAVEL_ECHO_SERVER_REDIS_PORT: "databaseConfig.redis.port",
LARAVEL_ECHO_SERVER_REDIS_PASSWORD: "databaseConfig.redis.password",
LARAVEL_ECHO_SERVER_REDIS_DB: "databaseConfig.redis.db",
LARAVEL_ECHO_SERVER_REDIS_PREFIX: "databaseConfig.redis.keyPrefix",
LARAVEL_ECHO_SERVER_PROTO: "protocol",
LARAVEL_ECHO_SERVER_SSL_CERT: "sslCertPath",
LARAVEL_ECHO_SERVER_SSL_KEY: "sslKeyPath",
Expand Down
4 changes: 2 additions & 2 deletions src/echo-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class EchoServer {
* Return a channel by its socket id.
*/
find(socket_id: string): any {
return this.server.io.sockets.connected[socket_id];
return this.server.io.sockets.sockets.get(socket_id);
}

/**
Expand Down Expand Up @@ -234,7 +234,7 @@ export class EchoServer {
*/
onDisconnecting(socket: any): void {
socket.on('disconnecting', (reason) => {
Object.keys(socket.rooms).forEach(room => {
socket.rooms.forEach(room => {
if (room !== socket.id) {
this.channel.leave(socket, room, reason);
}
Expand Down
Loading