typings
This commit is contained in:
parent
c577880aac
commit
6e2101c74c
1 changed files with 7 additions and 3 deletions
|
|
@ -131,6 +131,7 @@ const Event = require('../event-constants')
|
||||||
* @typedef {object} SimpleSocket
|
* @typedef {object} SimpleSocket
|
||||||
* @prop {(eventName: string, data: Emission) => void} emit
|
* @prop {(eventName: string, data: Emission) => void} emit
|
||||||
* @prop {(eventName: string, handler: (data: any) => void) => void} on
|
* @prop {(eventName: string, handler: (data: any) => void) => void} on
|
||||||
|
* @prop {{ query: { 'x-shockwallet-device-id': string }}} handshake
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* eslint-disable init-declarations */
|
/* eslint-disable init-declarations */
|
||||||
|
|
@ -342,16 +343,18 @@ class Mediator {
|
||||||
*/
|
*/
|
||||||
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 => {
|
||||||
try {
|
try {
|
||||||
if (Encryption.isNonEncrypted(eventName)) {
|
if (Encryption.isNonEncrypted(eventName)) {
|
||||||
return cb(data)
|
return cb(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data) {
|
if (!_data) {
|
||||||
return cb(data)
|
return cb(_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let data = _data
|
||||||
|
|
||||||
if (!deviceId) {
|
if (!deviceId) {
|
||||||
const error = {
|
const error = {
|
||||||
field: 'deviceId',
|
field: 'deviceId',
|
||||||
|
|
@ -396,6 +399,7 @@ class Mediator {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
/** @type {SimpleSocket['emit']} */
|
||||||
emit: (eventName, data) => {
|
emit: (eventName, data) => {
|
||||||
try {
|
try {
|
||||||
if (Encryption.isNonEncrypted(eventName)) {
|
if (Encryption.isNonEncrypted(eventName)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue