Skip to content

Commit

Permalink
Format message
Browse files Browse the repository at this point in the history
  • Loading branch information
oeway committed Jul 14, 2024
1 parent 97517a7 commit 924e461
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion javascript/src/hypha/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,10 @@ export class RPC extends MessageEmitter {
}

emit(main_message, extra_data) {
assert(typeof main_message === "object" && main_message.type, "Invalid message, must be an object with a type field.");
assert(
typeof main_message === "object" && main_message.type,
"Invalid message, must be an object with a type field."
);
let message_package = msgpack_packb(main_message);
if (extra_data) {
const extra = msgpack_packb(extra_data);
Expand Down
8 changes: 5 additions & 3 deletions javascript/src/hypha/websocket-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,18 @@ export async function connectToServer(config) {
await connection.disconnect();
}

wm.config["client_id"] = client_id
wm.config["client_id"] = client_id;
wm.export = _export;
wm.getPlugin = getPlugin;
wm.listPlugins = wm.listServices;
wm.disconnect = disconnect;
wm.registerCodec = rpc.register_codec.bind(rpc);

wm.emit = async function(message) {
assert(message && typeof message === "object", "message must be a dictionary");
assert(
message && typeof message === "object",
"message must be a dictionary"
);
assert("to" in message, "message must have a 'to' field");
assert("type" in message, "message must have a 'type' field");
assert(type !== "method", "message type cannot be 'method'");
Expand All @@ -270,7 +273,6 @@ export async function connectToServer(config) {
rpc.on(type, handler);
};


if (config.webrtc) {
await registerRTCService(wm, clientId + "-rtc", config.webrtc_config);
}
Expand Down

0 comments on commit 924e461

Please sign in to comment.