@creamery/socket.io-rpc
Advanced tools
Comparing version 1.0.1 to 1.0.3
@@ -0,2 +1,3 @@ | ||
export * from './common'; | ||
export * from './rpc-client'; | ||
export * from './rpc-server'; |
@@ -13,6 +13,5 @@ "use strict"; | ||
this.handlers = new Map(); | ||
this.client = socket_io_client_1.default(endpoint, { | ||
path: opts.path, | ||
this.client = socket_io_client_1.default(endpoint, Object.assign({}, opts, { | ||
transports: ['websocket'], | ||
}); | ||
})); | ||
this.client.on('notify', (seq, message) => { | ||
@@ -51,3 +50,3 @@ const cb = this.handlers.get(seq); | ||
if (error) { | ||
reject(`[SocketIO RPC Error] ${error.message}`); | ||
reject(new Error(`[SocketIO RPC Error] ${error.message}`)); | ||
return; | ||
@@ -54,0 +53,0 @@ } |
import SocketIO from 'socket.io'; | ||
export interface Vendor { | ||
id: string; | ||
[key: string]: any; | ||
} | ||
export interface Message { | ||
id: string; | ||
method: string; | ||
params: any[]; | ||
} | ||
export interface Notifaction { | ||
id: string; | ||
seq: number; | ||
channel: string; | ||
params: any[]; | ||
} | ||
export interface Response { | ||
id: string; | ||
result?: any; | ||
error?: ResponseError; | ||
} | ||
interface ResponseError { | ||
code: number; | ||
message: string; | ||
data?: any; | ||
} | ||
import { Vendor } from './common'; | ||
export declare function NotFoundResponse(id: string): { | ||
@@ -57,2 +33,1 @@ id: string; | ||
} | ||
export {}; |
@@ -57,7 +57,7 @@ "use strict"; | ||
const method = `on${channel}`; | ||
function callback(result) { | ||
function callback(...result) { | ||
emit('notify', seq, { | ||
id, | ||
method, | ||
params: Array.isArray(result) ? result : [result], | ||
params: result, | ||
}); | ||
@@ -64,0 +64,0 @@ } |
{ | ||
"name": "@creamery/socket.io-rpc", | ||
"version": "1.0.1", | ||
"version": "1.0.3", | ||
"description": "RPC for SocketIO", | ||
"main": "lib/index.js", | ||
"module": "lib/index.js", | ||
"files": [ | ||
@@ -7,0 +8,0 @@ "lib" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
15004
15
263