fix(core): update
This commit is contained in:
@ -29,7 +29,7 @@ export class Smartsocket {
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:member-ordering
|
||||
public async setExternalServer (serverType: 'smartexpress', serverArg: any) {
|
||||
public async setExternalServer(serverType: 'smartexpress', serverArg: any) {
|
||||
await this.socketServer.setExternalServer(serverType, serverArg);
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import { ISocketFunctionCall } from './smartsocket.classes.socketfunction';
|
||||
import { Objectmap } from '@pushrocks/lik';
|
||||
import { SocketFunction } from './smartsocket.classes.socketfunction';
|
||||
import { SocketConnection } from './smartsocket.classes.socketconnection';
|
||||
import { defaultLogger } from '@pushrocks/smartlog';
|
||||
|
||||
// export interfaces
|
||||
export type TSocketRequestStatus = 'new' | 'pending' | 'finished';
|
||||
@ -79,10 +80,15 @@ export class SocketRequest {
|
||||
/**
|
||||
* creates the response on the responding side
|
||||
*/
|
||||
createResponse() {
|
||||
let targetSocketFunction: SocketFunction = helpers.getSocketFunctionByName(
|
||||
public async createResponse(): Promise<void> {
|
||||
const targetSocketFunction: SocketFunction = helpers.getSocketFunctionByName(
|
||||
this.funcCallData.funcName
|
||||
);
|
||||
if (!targetSocketFunction) {
|
||||
defaultLogger.log('warn', `There is no SocketFunction defined for ${this.funcCallData.funcName}`);
|
||||
defaultLogger.log('warn', `So now response is being sent.`);
|
||||
return;
|
||||
}
|
||||
plugins.smartlog.defaultLogger.log('info', `invoking ${targetSocketFunction.name}`);
|
||||
targetSocketFunction.invoke(this.funcCallData).then(resultData => {
|
||||
plugins.smartlog.defaultLogger.log('info', 'got resultData. Sending it to requesting party.');
|
||||
|
@ -23,7 +23,10 @@ export class SocketServer {
|
||||
* starts the server with another server
|
||||
* also works with an express style server
|
||||
*/
|
||||
public async setExternalServer(serverType: 'smartexpress', serverArg: plugins.smartexpress.Server) {
|
||||
public async setExternalServer(
|
||||
serverType: 'smartexpress',
|
||||
serverArg: plugins.smartexpress.Server
|
||||
) {
|
||||
await serverArg.startedPromise;
|
||||
this.httpServer = serverArg.httpServer;
|
||||
}
|
||||
@ -51,8 +54,8 @@ export class SocketServer {
|
||||
// in case an external server has been set "this.standaloneServer" should be false
|
||||
if (this.httpServer && this.standaloneServer) {
|
||||
if (!this.smartsocket.options.port) {
|
||||
console.log('there should be a port specifed for smartsocket!')
|
||||
throw new Error('there should be a port specified for smartsocket')
|
||||
console.log('there should be a port specifed for smartsocket!');
|
||||
throw new Error('there should be a port specified for smartsocket');
|
||||
}
|
||||
this.httpServer.listen(this.smartsocket.options.port, () => {
|
||||
console.log(`Server started in standalone mode on ${this.smartsocket.options.port}`);
|
||||
|
@ -8,4 +8,14 @@ import * as shortid from 'shortid';
|
||||
import * as socketIo from 'socket.io';
|
||||
import * as socketIoClient from 'socket.io-client';
|
||||
|
||||
export { lik, smartlog, smarthash, smartdelay, smartexpress, smartpromise, shortid, socketIo, socketIoClient };
|
||||
export {
|
||||
lik,
|
||||
smartlog,
|
||||
smarthash,
|
||||
smartdelay,
|
||||
smartexpress,
|
||||
smartpromise,
|
||||
shortid,
|
||||
socketIo,
|
||||
socketIoClient
|
||||
};
|
||||
|
Reference in New Issue
Block a user