This commit is contained in:
Daniel Hübleitner
2019-09-20 22:39:07 +02:00
parent 968885767a
commit db9449aa2d
7 changed files with 31 additions and 37 deletions
+9 -1
View File
@@ -1,7 +1,15 @@
import * as Back from './src/Backend';
import * as Front from './src/Frontend';
import * as Types from './src/Types';
import * as Utils from './src/Utils';
import * as Interfaces from './src/Interfaces';
import * as Responses from './src/Responses';
export {
Back as Backend,
Front as Frontend
Front as Frontend,
Types,
Utils,
Interfaces,
Responses
}
+1 -9
View File
@@ -6,16 +6,8 @@ import bsock = require('bsock');
import * as T from './Types';
import * as U from './Utils';
import * as I from './Interfaces';
import * as R from './Responses';
export {
T as Types,
U as Utils,
I as Interfaces,
R as Responses
}
export class Server{
export class RPCServer{
private ws = http.createServer()
private io = bsock.createServer()
+1 -11
View File
@@ -3,24 +3,14 @@
var bsock = require('bsock')
import * as T from './Types';
import * as U from './Utils';
import * as I from './Interfaces';
import * as R from './Responses';
export {
T as Types,
U as Utils,
I as Interfaces,
R as Responses
}
//fix args with defaults like "force = true" -> "force"
function stripAfterEquals(str:string){
return str.split("=")[0]
}
export class Client implements I.Socket{
export class RPCSocket implements I.Socket{
private socket: I.Socket
constructor(public port:number, private server: string, private tls: boolean = false){
-1
View File
@@ -1,7 +1,6 @@
export type Outcome = "Success" | "Error"
/* Responses */
export class Response{
constructor(
public message?:string
+13 -8
View File
@@ -1,20 +1,25 @@
const path = require('path');
const frontendConf = {
module.exports = {
mode: 'production',
target: "web",
entry: path.resolve(__dirname, '..', 'js', 'src', 'Frontend.js'),
entry: path.resolve(__dirname, 'Frontend.ts'),
output: {
path: path.resolve(__dirname, '..', 'js', 'src'),
filename: "Frontend.js",
libraryTarget: 'commonjs',
path: path.resolve(__dirname, '../js'),
filename: 'Frontend.min.js',
libraryTarget: 'window',
},
resolve: {
extensions: [".ts", ".tsx", ".js"]
},
module: {
rules: [
{ test: /\.ts?$/, loader: "ts-loader" }
]
},
optimization: {
minimize: false,
},
}
module.exports = [frontendConf]
externals: {
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
import { Server } from '../src/Backend'
import { RPCServer } from '../src/Backend'
new Server(20000, [{
new RPCServer(20000, [{
name: "HelloWorldRPCGroup",
publicRPCs: () => [],
localRPCs: () => [{
+5 -5
View File
@@ -1,7 +1,7 @@
import { Client } from '../src/Frontend'
import { RPCSocket } from '../src/Frontend'
const client = new Client(20000, 'localhost')
client.connect().then(_ => {
client.info().then(console.log)
client["HelloWorldRPCGroup"].echo("x").then(console.log)
const socket = new RPCSocket(20000, 'localhost')
socket.connect().then(_ => {
socket.info().then(console.log)
socket["HelloWorldRPCGroup"].echo("x").then(console.log)
})