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 Back from './src/Backend';
import * as Front from './src/Frontend'; 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 { export {
Back as Backend, 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 T from './Types';
import * as U from './Utils'; import * as U from './Utils';
import * as I from './Interfaces'; import * as I from './Interfaces';
import * as R from './Responses';
export { export class RPCServer{
T as Types,
U as Utils,
I as Interfaces,
R as Responses
}
export class Server{
private ws = http.createServer() private ws = http.createServer()
private io = bsock.createServer() private io = bsock.createServer()
+1 -11
View File
@@ -3,24 +3,14 @@
var bsock = require('bsock') var bsock = require('bsock')
import * as T from './Types'; import * as T from './Types';
import * as U from './Utils';
import * as I from './Interfaces'; 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" //fix args with defaults like "force = true" -> "force"
function stripAfterEquals(str:string){ function stripAfterEquals(str:string){
return str.split("=")[0] return str.split("=")[0]
} }
export class Client implements I.Socket{ export class RPCSocket implements I.Socket{
private socket: I.Socket private socket: I.Socket
constructor(public port:number, private server: string, private tls: boolean = false){ constructor(public port:number, private server: string, private tls: boolean = false){
-1
View File
@@ -1,7 +1,6 @@
export type Outcome = "Success" | "Error" export type Outcome = "Success" | "Error"
/* Responses */
export class Response{ export class Response{
constructor( constructor(
public message?:string public message?:string
+13 -8
View File
@@ -1,20 +1,25 @@
const path = require('path'); const path = require('path');
const frontendConf = { module.exports = {
mode: 'production', mode: 'production',
target: "web", target: "web",
entry: path.resolve(__dirname, '..', 'js', 'src', 'Frontend.js'), entry: path.resolve(__dirname, 'Frontend.ts'),
output: { output: {
path: path.resolve(__dirname, '..', 'js', 'src'), path: path.resolve(__dirname, '../js'),
filename: "Frontend.js", filename: 'Frontend.min.js',
libraryTarget: 'commonjs', libraryTarget: 'window',
}, },
resolve: { resolve: {
extensions: [".ts", ".tsx", ".js"] extensions: [".ts", ".tsx", ".js"]
}, },
module: {
rules: [
{ test: /\.ts?$/, loader: "ts-loader" }
]
},
optimization: { optimization: {
minimize: false, minimize: false,
}, },
} externals: {
}
module.exports = [frontendConf] }
+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", name: "HelloWorldRPCGroup",
publicRPCs: () => [], publicRPCs: () => [],
localRPCs: () => [{ 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') const socket = new RPCSocket(20000, 'localhost')
client.connect().then(_ => { socket.connect().then(_ => {
client.info().then(console.log) socket.info().then(console.log)
client["HelloWorldRPCGroup"].echo("x").then(console.log) socket["HelloWorldRPCGroup"].echo("x").then(console.log)
}) })