Comparing version 0.1.4 to 0.1.5
@@ -19,5 +19,10 @@ "use strict"; | ||
sendMessage(msg, evtId) { | ||
this.sendEvent(new Any_1.ClientMessageEvent({ clientId: this.id, msg, evtId })); | ||
this.sendEvent(new Any_1.ClientMessageEvent({ | ||
fromId: this.id, | ||
clientId: this.id, | ||
msg, | ||
evtId, | ||
})); | ||
} | ||
} | ||
exports.Client = Client; |
@@ -25,6 +25,14 @@ "use strict"; | ||
case 'client': | ||
this.manager.broadcast(new Any_1.ClientMessageEvent({ clientId: req.toId, msg: response })); | ||
this.manager.broadcast(new Any_1.ClientMessageEvent({ | ||
fromId: client.id, | ||
clientId: req.toId, | ||
msg: response, | ||
})); | ||
break; | ||
case 'room': | ||
this.manager.broadcast(new W_A_1.RoomMessageEvent({ roomId: req.toId, msg: response })); | ||
this.manager.broadcast(new W_A_1.RoomMessageEvent({ | ||
fromId: client.id, | ||
roomId: req.toId, | ||
msg: response, | ||
})); | ||
break; | ||
@@ -31,0 +39,0 @@ } |
@@ -30,3 +30,7 @@ "use strict"; | ||
if (RoomJoinCommandProcessor.BROADCAST_TO_OTHER_IN_ROOM) { | ||
this.manager.broadcast(new W_A_1.RoomMessageEvent({ roomId: msg.roomId, msg: response })); | ||
this.manager.broadcast(new W_A_1.RoomMessageEvent({ | ||
fromId: client.id, | ||
roomId: msg.roomId, | ||
msg: response, | ||
})); | ||
} | ||
@@ -58,3 +62,7 @@ }); | ||
if (RoomExitCommandProcessor.BROADCAST_TO_OTHER_IN_ROOM) { | ||
this.manager.broadcast(new W_A_1.RoomMessageEvent({ roomId: msg.roomId, msg: response })); | ||
this.manager.broadcast(new W_A_1.RoomMessageEvent({ | ||
fromId: client.id, | ||
roomId: msg.roomId, | ||
msg: response, | ||
})); | ||
} | ||
@@ -61,0 +69,0 @@ }); |
@@ -19,3 +19,11 @@ "use strict"; | ||
room.clients.forEach(c => { | ||
this.manager.eventProcess(new Any_1.ClientMessageEvent({ clientId: c.id, msg: evt.data.msg }, evt.id)); | ||
// 不发送给自己 | ||
if (c.id === evt.data.fromId) { | ||
return; | ||
} | ||
this.manager.eventProcess(new Any_1.ClientMessageEvent({ | ||
fromId: evt.data.fromId, | ||
clientId: c.id, | ||
msg: evt.data.msg, | ||
}, evt.id)); | ||
}); | ||
@@ -22,0 +30,0 @@ }); |
@@ -7,2 +7,3 @@ import { BaseEvent } from '../common/BaseEvent'; | ||
export declare class ClientMessageEvent extends BaseEvent<{ | ||
fromId: string; | ||
clientId: string; | ||
@@ -9,0 +10,0 @@ msg: { |
@@ -26,2 +26,3 @@ import { BaseEvent } from '../common/BaseEvent'; | ||
export declare class RoomMessageEvent extends BaseEvent<{ | ||
fromId: string; | ||
roomId: string; | ||
@@ -28,0 +29,0 @@ msg: any; |
{ | ||
"name": "egg-ez-ws", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "easy websocket for egg.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62023
1560