Skip to content

Commit

Permalink
1.4.7: Added path option
Browse files Browse the repository at this point in the history
  • Loading branch information
darnfish committed Jun 27, 2020
1 parent d5ae148 commit 943290a
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 3 deletions.
3 changes: 3 additions & 0 deletions dist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,9 @@ Mesa's Server component allows for the following configuration to be passed in d
{
// Optional: port that Mesa should listen on. Defaults to 4000
port: number
// Optional: path that Mesa should listen on.
path: string

// Optional: namespace for Redis events. If you have multiple Mesa instances running on a cluster, you should use this
namespace: string

Expand Down
2 changes: 1 addition & 1 deletion dist/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cryb/mesa",
"version": "1.4.6",
"version": "1.4.7",
"description": "A scalable, modern & robust WebSocket wrapper",
"main": "index.js",
"repository": "https://github.com/crybapp/mesa",
Expand Down
2 changes: 2 additions & 0 deletions dist/server/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface IAuthenticationConfig {
}
interface IServerConfig {
port?: number;
path?: string;
namespace?: string;
redis?: RedisConfig;
server?: http.Server | https.Server;
Expand All @@ -59,6 +60,7 @@ declare class Server extends EventEmitter {
wss: WebSocket.Server;
clients: Client[];
port: number;
path: string;
namespace: string;
redis: Redis.Redis;
publisher: Redis.Redis;
Expand Down
4 changes: 4 additions & 0 deletions dist/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class Server extends events_1.EventEmitter {
options.server = config.server;
else
options.port = config.port;
if (config.path)
options.path = config.path;
this.wss = new ws_1.default.Server(options);
this.wss.on('connection', (socket, req) => this.registerConnection(socket, req));
}
Expand All @@ -98,6 +100,8 @@ class Server extends events_1.EventEmitter {
if (!config.port)
config.port = 4000;
this.port = config.port;
if (config.path)
this.path = config.path;
if (config.namespace)
this.namespace = config.namespace;
if (config.redis)
Expand Down
2 changes: 1 addition & 1 deletion examples/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
const { Client, Message } = require('../dist')
const { default: uuid } = require('../dist/utils/uuid.util')

const client = new Client('ws://localhost:4000')
const client = new Client('ws://localhost:4000/ws')

client.on('connected', async () => {
console.log('Connected to Mesa')
Expand Down
2 changes: 2 additions & 0 deletions examples/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const { default: Mesa, Message } = require('../dist')

const mesa = new Mesa({
port: 4000,
path: '/ws',

namespace: 'example'
})

Expand Down
3 changes: 3 additions & 0 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,9 @@ Mesa's Server component allows for the following configuration to be passed in d
{
// Optional: port that Mesa should listen on. Defaults to 4000
port: number
// Optional: path that Mesa should listen on.
path: string

// Optional: namespace for Redis events. If you have multiple Mesa instances running on a cluster, you should use this
namespace: string

Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cryb/mesa",
"version": "1.4.6",
"version": "1.4.7",
"description": "A scalable, modern & robust WebSocket wrapper",
"main": "index.js",
"repository": "https://github.com/crybapp/mesa",
Expand Down
10 changes: 10 additions & 0 deletions src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export interface IAuthenticationConfig {

interface IServerConfig {
port?: number
path?: string

namespace?: string

redis?: RedisConfig
Expand Down Expand Up @@ -85,6 +87,8 @@ class Server extends EventEmitter {
public clients: Client[] = []

public port: number
public path: string

public namespace: string

public redis: Redis.Redis
Expand Down Expand Up @@ -203,6 +207,9 @@ class Server extends EventEmitter {
else
options.port = config.port

if (config.path)
options.path = config.path

this.wss = new WebSocket.Server(options)
this.wss.on('connection', (socket, req) => this.registerConnection(socket, req))
}
Expand All @@ -215,6 +222,9 @@ class Server extends EventEmitter {

this.port = config.port

if (config.path)
this.path = config.path

if (config.namespace)
this.namespace = config.namespace

Expand Down

0 comments on commit 943290a

Please sign in to comment.