Fixing events fired multiple times
Callbacks for socket.io events were registered each time a disconnect was called, leading to message being dispatched plenty of times if there was several disconnections.
This commit is contained in:
parent
e50a4fd88b
commit
473c5aa052
2 changed files with 13 additions and 9 deletions
|
@ -158,6 +158,16 @@ export class Connection implements ConnectionInterface {
|
|||
token: this.token
|
||||
}
|
||||
});
|
||||
|
||||
//listen event
|
||||
this.disconnectServer();
|
||||
this.errorMessage();
|
||||
this.groupUpdatedOrCreated();
|
||||
this.groupDeleted();
|
||||
this.onUserJoins();
|
||||
this.onUserMoved();
|
||||
this.onUserLeft();
|
||||
|
||||
return this.connectSocketServer();
|
||||
})
|
||||
.catch((err) => {
|
||||
|
@ -178,15 +188,6 @@ export class Connection implements ConnectionInterface {
|
|||
* @param character
|
||||
*/
|
||||
connectSocketServer(): Promise<ConnectionInterface>{
|
||||
//listen event
|
||||
this.disconnectServer();
|
||||
this.errorMessage();
|
||||
this.groupUpdatedOrCreated();
|
||||
this.groupDeleted();
|
||||
this.onUserJoins();
|
||||
this.onUserMoved();
|
||||
this.onUserLeft();
|
||||
|
||||
return new Promise<ConnectionInterface>((resolve, reject) => {
|
||||
this.getSocket().emit(EventMessage.SET_PLAYER_DETAILS, {
|
||||
name: this.name,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue