fix(core): update

This commit is contained in:
Philipp Kunz 2019-04-08 19:56:21 +02:00
parent 9a177dc10b
commit 712270ba62
6 changed files with 49 additions and 22 deletions

View File

@ -14,4 +14,4 @@
"npmGlobalTools": [],
"npmAccessLevel": "public"
}
}
}

View File

@ -27,4 +27,4 @@
"@types/node-ipc": "^9.1.1",
"node-ipc": "^9.1.1"
}
}
}

26
readme.md Normal file
View File

@ -0,0 +1,26 @@
# @pushrocks/smartipc
node inter process communication
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartipc)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartipc)
* [github.com (source mirror)](https://github.com/pushrocks/smartipc)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartipc/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartipc/badges/master/build.svg)](https://gitlab.com/pushrocks/smartipc/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartipc/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartipc/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartipc.svg)](https://www.npmjs.com/package/@pushrocks/smartipc)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartipc/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartipc)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
## Usage
For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)

View File

@ -11,14 +11,17 @@ tap.test('should instantiate a valid instance', async () => {
ipcSpace: 'testSmartIpc',
type: 'server'
});
})
tap.test('should create a client', async (tools) => {
testIpc.start();
});
tap.test('should terminate the smartipc process', async () => {
tap.test('should create a client', async tools => {
const clientIpc = new smartipc.SmartIpc({
ipcSpace: 'testSmartIpc',
type: 'client'
});
clientIpc.sendMessage();
});
tap.test('should terminate the smartipc process', async () => {});
tap.start();

View File

@ -9,13 +9,13 @@ export interface ISmartIpcConstructorOptions {
ipcSpace: string;
}
export interface ISmartIpcHandlerPackage {
keyword: string;
handlerFunc: () => void;
}
export class SmartIpc {
public ipc = new plugins.nodeIpc.IPC();
public handlers: ISmartIpcHandlerPackage[] = [];
public options: ISmartIpcConstructorOptions;
@ -23,22 +23,21 @@ export class SmartIpc {
this.options = optionsArg;
}
/**
* connect to the channel
*/
public async start() {
switch (this.options.type) {
case 'server':
plugins.nodeIpc.config.id = this.options.ipcSpace;
this.ipc.config.id = this.options.ipcSpace;
const done = plugins.smartpromise.defer();
plugins.nodeIpc.serve(() => {
this.ipc.serve(() => {
done.resolve();
});
await done.promise;
break;
case 'client':
plugins.nodeIpc.connectTo(this.options.ipcSpace);
this.ipc.connectTo(this.options.ipcSpace);
default:
throw new Error('type of ipc is not valid. Must be "server" or "client"');
}
@ -54,7 +53,12 @@ export class SmartIpc {
/**
* regsiters a handler
*/
registerHandler (handlerPackage: ISmartIpcHandlerPackage) {
registerHandler(handlerPackage: ISmartIpcHandlerPackage) {
this.handlers.push(handlerPackage);
}
sendMessage() {
switch (this.options.type) {
}
}
}

View File

@ -2,15 +2,9 @@
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrx from '@pushrocks/smartrx';
export {
smartpromise,
smartrx
};
export { smartpromise, smartrx };
// third party scope
import * as nodeIpc from 'node-ipc';
export {
nodeIpc
};
export { nodeIpc };