disconnect action in mediator
This commit is contained in:
parent
45d6bd1099
commit
e7610ebc24
2 changed files with 30 additions and 1 deletions
|
|
@ -305,6 +305,7 @@ class Mediator {
|
||||||
this.socket.on(Action.SET_DISPLAY_NAME, this.setDisplayName)
|
this.socket.on(Action.SET_DISPLAY_NAME, this.setDisplayName)
|
||||||
this.socket.on(Action.SEND_PAYMENT, this.sendPayment)
|
this.socket.on(Action.SEND_PAYMENT, this.sendPayment)
|
||||||
this.socket.on(Action.SET_BIO, this.setBio)
|
this.socket.on(Action.SET_BIO, this.setBio)
|
||||||
|
this.socket.on(Action.DISCONNECT, this.disconnect)
|
||||||
|
|
||||||
this.socket.on(Event.ON_AVATAR, this.onAvatar)
|
this.socket.on(Event.ON_AVATAR, this.onAvatar)
|
||||||
this.socket.on(Event.ON_BLACKLIST, this.onBlacklist)
|
this.socket.on(Event.ON_BLACKLIST, this.onBlacklist)
|
||||||
|
|
@ -319,8 +320,12 @@ class Mediator {
|
||||||
this.socket.on(IS_GUN_AUTH, this.isGunAuth)
|
this.socket.on(IS_GUN_AUTH, this.isGunAuth)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @param {SimpleSocket} socket */
|
||||||
encryptSocketInstance = socket => {
|
encryptSocketInstance = socket => {
|
||||||
return {
|
return {
|
||||||
|
/**
|
||||||
|
* @type {SimpleSocket['on']}
|
||||||
|
*/
|
||||||
on: (eventName, cb) => {
|
on: (eventName, cb) => {
|
||||||
const deviceId = socket.handshake.query['x-shockwallet-device-id']
|
const deviceId = socket.handshake.query['x-shockwallet-device-id']
|
||||||
socket.on(eventName, data => {
|
socket.on(eventName, data => {
|
||||||
|
|
@ -1063,6 +1068,29 @@ class Mediator {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @param {Readonly<{ pub: string, token: string }>} body */
|
||||||
|
disconnect = async body => {
|
||||||
|
try {
|
||||||
|
const { pub, token } = body
|
||||||
|
|
||||||
|
await throwOnInvalidToken(token)
|
||||||
|
|
||||||
|
await API.Actions.disconnect(pub)
|
||||||
|
|
||||||
|
this.socket.emit(Action.DISCONNECT, {
|
||||||
|
ok: true,
|
||||||
|
msg: null,
|
||||||
|
origBody: body
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
this.socket.emit(Action.DISCONNECT, {
|
||||||
|
ok: true,
|
||||||
|
msg: null,
|
||||||
|
origBody: body
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ const Actions = {
|
||||||
SEND_PAYMENT: "SEND_PAYMENT",
|
SEND_PAYMENT: "SEND_PAYMENT",
|
||||||
SET_AVATAR: "SET_AVATAR",
|
SET_AVATAR: "SET_AVATAR",
|
||||||
SET_DISPLAY_NAME: "SET_DISPLAY_NAME",
|
SET_DISPLAY_NAME: "SET_DISPLAY_NAME",
|
||||||
SET_BIO: "SET_BIO"
|
SET_BIO: "SET_BIO",
|
||||||
|
DISCONNECT: "DISCONNECT"
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Actions;
|
module.exports = Actions;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue