Skip to content

Commit

Permalink
Release 1.0.0-beta.3.1 🚀
Browse files Browse the repository at this point in the history
- Implemented host ping pong mechanism
  • Loading branch information
Jonathan committed May 28, 2018
1 parent eba47e7 commit 7722206
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onixjs/core",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.3.1",
"description": "An Enterprise Grade NodeJS Platform that implements Industry Standards and Patterns in order to provide Connectivity, Stability, High-Availability and High-Performance.",
"main": "dist/src/index.js",
"scripts": {
Expand Down
22 changes: 17 additions & 5 deletions src/core/host.broker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,18 @@ export class HostBroker {
// Listen for WebSocket Requests
wss.on('connection', ws => {
// Register a message event listener
ws.on('message', (data: string) =>
this.wsHandler(ws, Utils.IsJsonString(data) ? JSON.parse(data) : data),
);
ws.on('message', (data: string) => {
// Verify if request is a ping timestamp
if (!isNaN(parseInt(data))) {
ws.send(data);
// Else handle as an application operation
} else {
this.wsHandler(
ws,
Utils.IsJsonString(data) ? JSON.parse(data) : data,
);
}
});
// Add On Close Listener
ws.onclose = async () => await this.close(ws);
// Add On Error Listener
Expand Down Expand Up @@ -106,7 +115,10 @@ export class HostBroker {
}
// Route Message to the right application
const callee: string = operation.message.rpc.split('.').shift() || '';
if (this.apps[callee]) {
if (
this.apps[callee] &&
this.subscriptions[operation.message.request.metadata.subscription]
) {
const index: number = this.subscriptions[
operation.message.request.metadata.subscription
]
Expand All @@ -129,7 +141,7 @@ export class HostBroker {
// through std io stream
this.apps[callee].process.send(operation);
} else {
throw new Error('Unable to find callee application');
throw new Error('Unable to find callee application or subscription');
}
}
/**
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class OnixJS {
* @description Current Onix Version.
*/
get version(): string {
return '1.0.0-beta.3';
return '1.0.0-beta.3.1';
}
/**
* @property router
Expand Down

0 comments on commit 7722206

Please sign in to comment.