diff --git a/package.json b/package.json index a5affa2..4c3db45 100644 --- a/package.json +++ b/package.json @@ -18,14 +18,15 @@ }, "homepage": "https://gitlab.com/pushrocks/smartipc#README", "dependencies": { - "@types/lodash": "^4.14.36", - "beautylog": "^5.0.23", - "lodash": "^4.16.2", + "@types/lodash": "^4.14.50", + "beautylog": "^6.0.0", + "lodash": "^4.17.4", + "threads": "^0.7.2", "typings-global": "^1.0.14" }, "devDependencies": { "@types/should": "^8.1.30", - "should": "^11.1.0", + "should": "^11.1.2", "typings-test": "^1.0.3" } } diff --git a/test/child.d.ts b/test/child.d.ts new file mode 100644 index 0000000..e69de29 diff --git a/test/child.js b/test/child.js new file mode 100644 index 0000000..9bffa23 --- /dev/null +++ b/test/child.js @@ -0,0 +1,4 @@ +"use strict"; +const smartipc = require("../dist/index"); +let localChild = new smartipc.IpcChild({}); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hpbGQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJjaGlsZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMENBQXlDO0FBRXpDLElBQUksVUFBVSxHQUFHLElBQUksUUFBUSxDQUFDLFFBQVEsQ0FBQyxFQUFFLENBQUMsQ0FBQSJ9 \ No newline at end of file diff --git a/ts/smartipc.classes.ipcchild.ts b/ts/smartipc.classes.ipcchild.ts deleted file mode 100644 index 5a5d285..0000000 --- a/ts/smartipc.classes.ipcchild.ts +++ /dev/null @@ -1,22 +0,0 @@ -import * as plugins from './smartipc.plugins' -import { IpcTarget } from './smartipc.classes.ipctarget' - -export interface IpcChildConstructorOptions { - -} - -let defaultOptions: IpcChildConstructorOptions = { - -} - -/** - * class Ipcclient represents the child process - */ -export class IpcChild extends IpcTarget { - constructor(optionsArg: IpcChildConstructorOptions) { - super({alias: 'child'}) - } - call(ipctarget,targetFunction,dataArg) { - - } -} \ No newline at end of file diff --git a/ts/smartipc.classes.ipcmaster.ts b/ts/smartipc.classes.ipcmaster.ts deleted file mode 100644 index 33a6721..0000000 --- a/ts/smartipc.classes.ipcmaster.ts +++ /dev/null @@ -1,48 +0,0 @@ -import * as plugins from './smartipc.plugins' -import { IpcTarget } from './smartipc.classes.ipctarget' - -export interface IIpcServeOptions { - -} - -let defaultOptions: IIpcServeOptions = { - -} - -export interface IIpcChildProcess { - alias: string - filePath: string - childProcess: plugins.childProcess.ChildProcess -} - -/** - * class Ipcserve is represents the master process for any chil processes - */ -export class IpcMaster extends IpcTarget { - ipcOptions: IIpcServeOptions - childProcessArray: IIpcChildProcess[] - constructor(ipcOptionsArg: IIpcServeOptions) { - super({alias: 'master'}) - this.ipcOptions = plugins.lodash.merge({},defaultOptions,ipcOptionsArg) - } - - /** - * spawns a child process - */ - spawnProcess(filePath: string, alias: string) { - - let childProcess = plugins.childProcess.fork('ls', ['-lh', '/usr']) - - childProcess.stdout.on('data', (data) => { - console.log(`stdout: ${data}`) - }) - - childProcess.stderr.on('data', (data) => { - console.log(`stderr: ${data}`) - }) - - childProcess.on('close', (code) => { - console.log(`child process exited with code ${code}`) - }) - } -} \ No newline at end of file diff --git a/ts/smartipc.classes.ipctarget.ts b/ts/smartipc.classes.ipctarget.ts deleted file mode 100644 index cb0e883..0000000 --- a/ts/smartipc.classes.ipctarget.ts +++ /dev/null @@ -1,27 +0,0 @@ -import * as plugins from './smartipc.plugins' - -export interface ITargetConstructorOptions { - alias: string -} - -/** - * - */ -export class IpcTarget { - alias: string - private funcArray: any[] - - constructor(optionsArg: ITargetConstructorOptions) { - this.alias = optionsArg.alias - } - - /** - * registers a function - */ - register(funcArrayArg: any[]) { - for (let funcItem of funcArrayArg){ - this.funcArray.push(funcItem) - } - } - -} diff --git a/ts/smartipc.classes.thread.ts b/ts/smartipc.classes.thread.ts new file mode 100644 index 0000000..7203b35 --- /dev/null +++ b/ts/smartipc.classes.thread.ts @@ -0,0 +1,32 @@ +import 'typings-global' + +let threads = require('threads') + +export interface IThreadFunction { + (input, done): void +} + +export class Thread { + thread + constructor(functionArg: IThreadFunction) { + this.thread = threads.spawn(functionArg) + this.thread.on('error', function() { + + }) + this.thread.on('exit' function() { + + }) + this.thread.on('message') + } + + /** + * sends a message to the spawned process + */ + send(message) { + this.thread.send(message) + } + + /** + * sends a message to + */ +} \ No newline at end of file diff --git a/ts/smartipc.plugins.ts b/ts/smartipc.plugins.ts deleted file mode 100644 index 169882a..0000000 --- a/ts/smartipc.plugins.ts +++ /dev/null @@ -1,4 +0,0 @@ -import 'typings-global' -export import beautylog = require('beautylog') -export import lodash = require('lodash') -export import childProcess = require('child_process')