0.4.9 • Published 4 years ago

@rc-ex/ws-legacy v0.4.9

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

WebSocket Extension (legacy and deprecated)

WebSocket Extension adds support for WebSocket protocol.

Install

yarn add @rc-ex/ws-legacy

Usage

import RingCentral from '@rc-ex/core';
import WebSocketExtension from '@rc-ex/ws-legacy';

const rc = new RingCentral(...);
const webSocketExtension = new WebSocketExtension(webSocketOptions);
await rc.installExtension(webSocketExtension);

You can setup subscriptions:

await webSocketExtension.subscribe(
    ['/restapi/v1.0/account/~/extension/~/message-store'],
    event => {
       ...
    }
);

You can also make Rest API calls over WebSocket if you specified webSocketOptions.restOverWebSocket as true:

const webSocketExtension = new WebSocketExtension({
  server: '...',
  restOverWebSocket: true
});
await rc.installExtension(webSocketExtension);

const extInfo = await rc.restapi().account().extension().get();
console.log(extInfo.id);

WebSocketOptions

WebSocketExtension constructor requires WebSocketOptions as parameter:

type WebSocketOptions = {
  server: string;
  restOverWebSocket?: boolean;
};

server

server defines WebSocket server uri.

For sandbox it is wss://ws-api.devtest.ringcentral.com/ws while for production it is wss://ws-api.ringcentral.com/ws.

You may have different server uri depending on your testing/running environment.

restOverWebSocket

restOverWebSocket indicates whether to make Rest API call over WebSocket protocol.

Default value is false.

Please note that, not all Rest API calls can be done over WebSocket protocol. The following are not supported at the moment:

  • Binary downloading
  • form-data/multipart POST / PUT
  • Authorization, such as get token and revoke token

If restOverWebSocket is true and an Rest API call cannot be done over WebSocket, it will be done over HTTPS instead.

0.4.9

4 years ago

0.4.8

4 years ago

0.4.7

4 years ago

0.4.6

4 years ago

0.4.5

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago