Skip to the content.

ROPE client

Client for the Remote Objects, Procedures and Events protocol

ROPE is a protocol that allows clients to have a shallow copy of the server state and objects, being able to call methods on them as if they were in local, and keep sync’ed with server side updates, also when multiple clients are connected to the same server instance or between reconnections. Under the hood it makes use of a WebSocket connection and JsonRPC 2.0 protocol.

This repository provides the canonical client for ROPE protocol, including support for multiplexing multiple client instances over a single connection and sync’ed state.

API

new RopeClient(url, [WebSocket])

Constructor of the client.

url can also be an object with the same fields.

readyState

Property showing the actual state of the connection, possible values are CONNECTING, OPEN, CLOSSING, CLOSED and CONNECTED. CONNECTED state is only reached when after receiving initial payload from server with its actual state.

close()

Close and unregister the client. If it’s the last one for that particular URL, then it also closes the connection itself. It can be open again later by calling the open() method.

open(url)

Open a connection with the ROPE server instance. It’s automatically called if url argument is provided to the class constructor. If client is already in opening or open state it will throw an error.

events