A lightweight JSON RPC client & server
Server code : ``` const { WebSocketChannel } = require('async-call-rpc/utils/node/websocket.server') const { Msgpack_Serialization } = require('async-call-rpc/utils/node/msgpack') const { AsyncCall } = require('async-call-rpc') const { Server } = require('ws') const {compute} = require('./methods'); const ws = new Server({ port: 3456 }) const channel = new WebSocketChannel(ws) AsyncCall(compute, { channel: channel, serializer: Msgpack_Serialization() }) ``` Client code : ``` const {WebSocketChannel} = require('async-call-rpc/utils/node/websocket.server') const {Msgpack_Serialization} = require('async-call-rpc/utils/node/msgpack') const {AsyncCall} = require('async-call-rpc') const {WebSocket} = require('ws'); const {compute} = require("./methods"); const socket = new WebSocket('ws://localhost:3456/'); const channel = new WebSocketChannel(socket) const server = AsyncCall(compute, {channel: channel, serializer: Msgpack_Serialization()}); server.compute('a') ``` methods.js : ``` function compute(data) { return data; } module.exports = {compute} ``` it throws : ``` (node:27940) UnhandledPromiseRejectionWarning: TypeError: channel.send is not a function at sendPayload (/home/crooked/Desktop/work/async-call-rpc/node_modules/async-call-rpc/out/base.js:655:28) at processTicksAndRejections (internal/process/task_queues.js:95:5) (Use `node --trace-warnings ...` to show where the warning was created) (node:27940) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:27940) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. ``` what am I doing wrong ? thanks in advance.
This issue appears to be discussing a feature request or bug report related to the repository. Based on the content, it seems to be resolved. The issue was opened by Baker68 and has received 1 comments.