fix(core): update
This commit is contained in:
parent
4678e44d16
commit
139c71a451
@ -1,3 +1,4 @@
|
||||
export * from './http.interfaces';
|
||||
export * from './universechannel.interfaces';
|
||||
export * from './universemessage.interfaces';
|
||||
export * from './universeactions.interfaces';
|
||||
|
9
ts/interfaces/universeactions.interfaces.ts
Normal file
9
ts/interfaces/universeactions.interfaces.ts
Normal file
@ -0,0 +1,9 @@
|
||||
export type IServerCallActions = 'subscribe' | 'sendmessage' | 'unsubscribe';
|
||||
|
||||
/**
|
||||
* the interface for a subscription
|
||||
*/
|
||||
export interface IServerCallSubscribeActionPayload {
|
||||
name: string;
|
||||
passphrase: string;
|
||||
}
|
@ -19,7 +19,7 @@ export interface IClientOptions {
|
||||
*/
|
||||
export class ClientUniverse {
|
||||
public options;
|
||||
public socketClient: plugins.smartsocket.SmartsocketClient;
|
||||
public smartsocketClient: plugins.smartsocket.SmartsocketClient;
|
||||
public observableIntake: plugins.smartrx.ObservableIntake<UniverseMessage>;
|
||||
|
||||
public channelCache = new Objectmap<ClientUniverseChannel>();
|
||||
@ -74,7 +74,7 @@ export class ClientUniverse {
|
||||
}
|
||||
|
||||
public close() {
|
||||
this.socketClient.disconnect();
|
||||
this.smartsocketClient.disconnect();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,7 +82,7 @@ export class ClientUniverse {
|
||||
* since password validation is done through other means, a connection should always be possible
|
||||
*/
|
||||
private async checkConnection(): Promise<void> {
|
||||
if (!this.socketClient && !this.observableIntake) {
|
||||
if (!this.smartsocketClient && !this.observableIntake) {
|
||||
const parsedURL = url.parse(this.options.serverAddress);
|
||||
const socketConfig: plugins.smartsocket.ISmartsocketClientOptions = {
|
||||
alias: process.env.SOCKET_ALIAS || 'someclient',
|
||||
@ -92,9 +92,30 @@ export class ClientUniverse {
|
||||
url: parsedURL.protocol + '//' + parsedURL.hostname
|
||||
};
|
||||
console.log(socketConfig);
|
||||
this.socketClient = new SmartsocketClient(socketConfig);
|
||||
this.smartsocketClient = new SmartsocketClient(socketConfig);
|
||||
this.observableIntake = new plugins.smartrx.ObservableIntake();
|
||||
await this.socketClient.connect();
|
||||
|
||||
// lets define some basic actions
|
||||
|
||||
/**
|
||||
* should handle a forced unsubscription by the server
|
||||
*/
|
||||
const unsubscribe = new plugins.smartsocket.SocketFunction({
|
||||
funcName: 'unsubscribe',
|
||||
allowedRoles: [],
|
||||
funcDef: async () => {},
|
||||
});
|
||||
|
||||
/**
|
||||
* should handle a message reception
|
||||
*/
|
||||
const receiveMessage = async () => {
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
await this.smartsocketClient.connect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,11 @@ export class ClientUniverseChannel implements interfaces.IUniverseChannel {
|
||||
* tells the universe about this instances interest into a channel
|
||||
*/
|
||||
public async subscribe() {
|
||||
this.clientUniverse.socketClient;
|
||||
const serverCallActionName: interfaces.IServerCallActions = 'subscribe';
|
||||
const serverCallActionPayload: interfaces.IServerCallSubscribeActionPayload = {
|
||||
name: this.name,
|
||||
passphrase: this.passphrase
|
||||
};
|
||||
this.clientUniverse.smartsocketClient.serverCall(serverCallActionName, serverCallActionPayload);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import * as plugins from './smartuniverse.plugins';
|
||||
|
||||
import * as interfaces from './interfaces';
|
||||
import { IUniverseMessage } from './interfaces';
|
||||
|
||||
export class ClientUniverseMessage implements interfaces.IUniverseMessage {
|
||||
// ======
|
||||
@ -12,17 +13,22 @@ export class ClientUniverseMessage implements interfaces.IUniverseMessage {
|
||||
// INSTANCE
|
||||
// ========
|
||||
|
||||
// properties
|
||||
public id: string;
|
||||
|
||||
public timestamp: number;
|
||||
public smartTimestamp: plugins.smarttime.TimeStamp;
|
||||
|
||||
public messageText: string;
|
||||
public passphrase: string;
|
||||
public payload: any;
|
||||
public payloadStringType;
|
||||
public targetChannelName: string;
|
||||
constructor(messageArg, payloadArg) {}
|
||||
|
||||
getAsJsonForPayload() {}
|
||||
constructor(messageArg: IUniverseMessage, payloadArg) {
|
||||
for (const key of Object.keys(messageArg)) {
|
||||
this[key] = messageArg[key];
|
||||
}
|
||||
}
|
||||
|
||||
getAsJsonForPayload() {};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user