UNPKG

raas-server

Version:
68 lines 2.91 kB
"use strict"; // import { Server } from '../server'; // import { RaasClient } from 'raas-client'; // import { Protocol } from 'raas-core'; // export class ClientDriver { // private server: Server; // private client: RaasClient; // connect(timeout: number = 2000, testPort: number, host: string, port: number): Promise<void> { // this.host = host; // this.port = port; // return new Promise((resolve, reject) => { // const timer = setTimeout(() => { // return reject(new Error(`Failed to establish connection to ${this.host}:${this.port} within time`)); // }, timeout); // this.socket = net.connect(this.port, this.host); // this.socket.on('connect', () => { // this.connection = rpc.createMessageConnection( // new rpc.StreamMessageReader(this.socket), // new rpc.StreamMessageWriter(this.socket)); // this.connection.listen(); // this.discoveryUtil = new Discovery(this.connection, this.emitter); // this.serverUtil = new ServerModel(this.connection, this.emitter); // this.launcherUtil = new ServerLauncher(this.connection, this.emitter); // clearTimeout(timer); // this.emitter.emit('connected'); // resolve(); // }); // this.socket.on('error', () => { // // this.disconnect(); // }); // this.socket.on('close', () => { // // this.disconnect(); // }); // }); // } // start(host: string, port: number): void { // this.server = new Server(); // this.server.start(port); // this.client = new RaasClient(); // this.listen(); // this.client.connect(2000, host, port); // } // drive(): void { // (async () => { // const config: Protocol.ServerConfig = new Protocol.ServerConfigImpl(); // const status = await this.client.startServerAsync(config); // console.log(`started server. response status is: ${JSON.stringify(status)}`); // })(); // } // listen(): void { // this.client.onConnected(() => { // console.log('we rolling!!!!'); // console.log('starting driver'); // driver.drive(); // }); // this.client.onDisconnected(() => { // console.log('we rolling ####'); // }); // this.client.onServerStateChange(handle => { // console.log('onServerStateChange!!!!!'); // console.log(`handle is: ${JSON.stringify(handle)}`); // }); // } // } // const driver = new ClientDriver(); // const port = process.env.PORT || 61435; // driver.start('localhost', Number(port)); //# sourceMappingURL=clientDriver.js.map