Skip to content

Commit

Permalink
Support passing server object
Browse files Browse the repository at this point in the history
  • Loading branch information
oeway committed Jun 28, 2024
1 parent 2564d98 commit 788de8f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
8 changes: 7 additions & 1 deletion javascript/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@ interface hRPC extends MessageEmitter {
decode(aObject: any): Promise<any>;
}

interface HyphaServer {
url: string;
WebSocketClass: any;
}

interface ServerConfig {
server_url: string;
server?: HyphaServer;
server_url?: string;
client_id?: string;
workspace?: string;
token?: string;
Expand Down
2 changes: 1 addition & 1 deletion javascript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion javascript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "imjoy-rpc",
"version": "0.5.55",
"version": "0.5.56",
"description": "Remote procedure calls for ImJoy.",
"module": "index.js",
"types": "index.d.ts",
Expand Down
10 changes: 9 additions & 1 deletion javascript/src/hypha/websocket-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ export async function login(config) {
}

export async function connectToServer(config) {
if (config.server) {
config.server_url = config.server_url || config.server.url;
config.WebSocketClass =
config.WebSocketClass || config.server.WebSocketClass;
}
let clientId = config.client_id;
if (!clientId) {
clientId = randId();
Expand Down Expand Up @@ -390,7 +395,10 @@ class LocalWebSocket {
}
}

export function setupLocalClient({ enable_execution = false, on_ready = null }) {
export function setupLocalClient({
enable_execution = false,
on_ready = null
}) {
return new Promise((resolve, reject) => {
const context = typeof window !== "undefined" ? window : self;
const isWindow = typeof window !== "undefined";
Expand Down
2 changes: 1 addition & 1 deletion python/imjoy_rpc/VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "0.5.55"
"version": "0.5.56"
}

0 comments on commit 788de8f

Please sign in to comment.