Skip to content

Commit

Permalink
Small improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
vdfdev committed Aug 11, 2021
1 parent 650e936 commit 0768853
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/server/transport/socketio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,16 @@ export class SocketIO {
}

private subscribePubSubChannel(matchID: string, game: Game) {
this.pubSub.subscribe(
getPubSubChannelId(matchID),
(payload: IntermediateTransportData) => {
this.roomInfo.get(matchID).forEach((clientID) => {
const client = this.clientInfo.get(clientID);
const data = getFilterPlayerView(game)(client.playerID, payload);
emit(client.socket, data);
});
}
);
const filterPlayerView = getFilterPlayerView(game);
const broadcast = (payload: IntermediateTransportData) => {
this.roomInfo.get(matchID).forEach((clientID) => {
const client = this.clientInfo.get(clientID);
const data = filterPlayerView(client.playerID, payload);
emit(client.socket, data);
});
};

this.pubSub.subscribe(getPubSubChannelId(matchID), broadcast);
}

private unsubscribePubSubChannel(matchID: string) {
Expand Down

0 comments on commit 0768853

Please sign in to comment.