@noveo/dual-rpc-ws
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -20,2 +20,3 @@ declare type id = string; | ||
requests: Map<id, Request>; | ||
handshake: (connected: boolean) => void; | ||
constructor(cid: id, address: string, protocols?: string | string[]); | ||
@@ -22,0 +23,0 @@ call(method: string, params: object): Promise<object>; |
@@ -30,2 +30,3 @@ "use strict"; | ||
this.requests = new Map(); | ||
this.handshake = () => { }; | ||
this.addEventListener('open', () => { | ||
@@ -45,3 +46,3 @@ this.send(JSON.stringify({ | ||
if (message.method === 'connect') { | ||
this.dispatchEvent(new CustomEvent('handshake', { detail: message.params.result })); | ||
this.handshake(message.params.result); | ||
return; | ||
@@ -48,0 +49,0 @@ } |
import WebSocket, { ServerOptions as WSServerOptions } from 'ws'; | ||
declare type id = string; | ||
interface ServerOptions extends WSServerOptions { | ||
export interface ServerOptions extends WSServerOptions { | ||
handshake?: (token: id) => Promise<boolean>; | ||
} | ||
export interface DeviceSocket extends WebSocket { | ||
token: id; | ||
} | ||
declare class Request { | ||
@@ -7,0 +10,0 @@ private server; |
{ | ||
"name": "@noveo/dual-rpc-ws", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "Remote procedure call", | ||
@@ -11,3 +11,3 @@ "browser": "build/client.js", | ||
"build": "tsc --build tsconfig.json && tsc --build tsconfig.client.json", | ||
"prepublish": "npm run-script build" | ||
"prepare": "npm run-script build" | ||
}, | ||
@@ -14,0 +14,0 @@ "author": "", |
Sorry, the diff of this file is not supported yet
25032
412