@pathscale/wss-adapter 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,7 @@ interface IConfiguration {
30
30
  }) => void;
31
31
  }
32
32
  interface IServiceConnect {
33
- connect<T>(payload: string | string[] | undefined): Promise<T>;
33
+ connect<T>(payload: string | string[] | undefined, remote?: string): Promise<T>;
34
34
  disconnect: () => void;
35
35
  }
36
36
  interface IWssAdapter {
@@ -37,8 +37,8 @@ wssAdapter.configure = function (configuration) {
37
37
  // construct services objects with two simple functions
38
38
  // intended use: `wssAdapter.services.admin.connect([1, 2, 3])` or `wssAdapter.services.auth.connect([1, 2, 3])`
39
39
  wssAdapter.services[serviceName] = {
40
- connect: function (payload) {
41
- return connectHandler(serviceName, serviceConfig, payload);
40
+ connect: function (payload, remote) {
41
+ return connectHandler(serviceName, serviceConfig, payload, remote);
42
42
  },
43
43
  disconnect: function () { return disconnectHandler(serviceName); },
44
44
  };
@@ -55,9 +55,9 @@ wssAdapter.configure = function (configuration) {
55
55
  _loop_1(serviceName, serviceConfig);
56
56
  }
57
57
  };
58
- var connectHandler = function (serviceName, serviceConfig, payload) {
58
+ var connectHandler = function (serviceName, serviceConfig, payload, remote) {
59
59
  return new Promise(function (resolve, reject) {
60
- store.sessions[serviceName] = new WebSocket(serviceConfig.remote, payload);
60
+ store.sessions[serviceName] = new WebSocket(remote || serviceConfig.remote, payload);
61
61
  store.sessions[serviceName].onmessage = function (event) {
62
62
  var _a;
63
63
  var response = JSON.parse(event.data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pathscale/wss-adapter",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Websocket adapter for the Pathscale WSS",
5
5
  "main": "dist/wssAdapter.js",
6
6
  "types": "dist/wssAdapter.d.ts",
package/types/index.ts CHANGED
@@ -32,7 +32,10 @@ interface IConfiguration {
32
32
  }
33
33
 
34
34
  interface IServiceConnect {
35
- connect<T>(payload: string | string[] | undefined): Promise<T>
35
+ connect<T>(
36
+ payload: string | string[] | undefined,
37
+ remote?: string
38
+ ): Promise<T>
36
39
  disconnect: () => void
37
40
  }
38
41
 
package/wssAdapter.ts CHANGED
@@ -44,8 +44,8 @@ wssAdapter.configure = (configuration) => {
44
44
  // construct services objects with two simple functions
45
45
  // intended use: `wssAdapter.services.admin.connect([1, 2, 3])` or `wssAdapter.services.auth.connect([1, 2, 3])`
46
46
  wssAdapter.services[serviceName] = {
47
- connect: <T>(payload: string | string[] | undefined) =>
48
- connectHandler<T>(serviceName, serviceConfig, payload),
47
+ connect: <T>(payload: string | string[] | undefined, remote?: string) =>
48
+ connectHandler<T>(serviceName, serviceConfig, payload, remote),
49
49
  disconnect: () => disconnectHandler(serviceName),
50
50
  }
51
51
 
@@ -65,10 +65,14 @@ wssAdapter.configure = (configuration) => {
65
65
  const connectHandler = <T>(
66
66
  serviceName: string,
67
67
  serviceConfig: IServiceConfig,
68
- payload: string | string[] | undefined
68
+ payload: string | string[] | undefined,
69
+ remote?: string
69
70
  ) => {
70
71
  return new Promise((resolve, reject) => {
71
- store.sessions[serviceName] = new WebSocket(serviceConfig.remote, payload)
72
+ store.sessions[serviceName] = new WebSocket(
73
+ remote || serviceConfig.remote,
74
+ payload
75
+ )
72
76
 
73
77
  store.sessions[serviceName].onmessage = function (event: { data: string }) {
74
78
  const response = JSON.parse(event.data)