@chijs/client
Advanced tools
Comparing version 0.0.3 to 0.0.4
import { ManagerOptions, Socket, SocketOptions } from 'socket.io-client'; | ||
import { RpcHub, IClientRpcFns, IServerClientRpcFns } from '@chijs/core'; | ||
export declare class ChiClient<M = IClientRpcFns> extends RpcHub<IServerClientRpcFns, M> { | ||
private _socket; | ||
import { RpcHub, IClientRpcFns, IServerClientRpcFns, RpcWrapped } from '@chijs/core'; | ||
export declare class ChiClient { | ||
socket: Socket; | ||
hub: RpcHub<IServerClientRpcFns, IClientRpcFns>; | ||
service: RpcWrapped<IServerClientRpcFns, 'app:service:'>; | ||
plugin: RpcWrapped<IServerClientRpcFns, 'app:plugin:'>; | ||
misc: RpcWrapped<IServerClientRpcFns, 'app:misc:'>; | ||
constructor(uri: string | Partial<ManagerOptions & SocketOptions>, opts?: Partial<ManagerOptions & SocketOptions>); | ||
get socket(): Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap>; | ||
} |
import { io } from 'socket.io-client'; | ||
import { RpcHub } from '@chijs/core'; | ||
export class ChiClient extends RpcHub { | ||
_socket; | ||
import { RpcHub, createRpcWrapper } from '@chijs/core'; | ||
export class ChiClient { | ||
socket; | ||
hub; | ||
service; | ||
plugin; | ||
misc; | ||
constructor(uri, opts) { | ||
const socket = io(uri, opts); | ||
super((msg) => void socket.emit('rpc', msg)); | ||
socket.on('rpc', (msg) => this.handle(msg)); | ||
this._socket = socket; | ||
this.socket = io(uri, opts); | ||
this.hub = new RpcHub((msg) => void this.socket.emit('rpc', msg)); | ||
this.socket.on('rpc', (msg) => this.hub.handle(msg)); | ||
this.service = createRpcWrapper(this.hub, 'app:service:'); | ||
this.plugin = createRpcWrapper(this.hub, 'app:plugin:'); | ||
this.misc = createRpcWrapper(this.hub, 'app:misc:'); | ||
} | ||
get socket() { | ||
return this._socket; | ||
} | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@chijs/client", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"main": "lib/index.js", | ||
@@ -19,3 +19,3 @@ "license": "AGPL-3.0", | ||
"dependencies": { | ||
"@chijs/core": "^0.0.3", | ||
"@chijs/core": "^0.0.4", | ||
"socket.io-client": "^4.5.1" | ||
@@ -26,3 +26,4 @@ }, | ||
"build": "node ../../scripts/build.mjs --package client", | ||
"prepare": "node ../../scripts/build.mjs --package client --rebuild" | ||
"prepare": "node ../../scripts/build.mjs --package client --rebuild", | ||
"test": "mocha" | ||
}, | ||
@@ -29,0 +30,0 @@ "files": [ |
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
2884
27
Updated@chijs/core@^0.0.4