2018-03-13 05:15:40 +00:00
|
|
|
import * as plugins from './smartuniverse.plugins';
|
|
|
|
|
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
import { IServerGetMessagesRequestBody, IServerPutMessageRequestBody } from './smartuniverse.classes.universe'
|
|
|
|
|
2018-03-15 00:05:13 +00:00
|
|
|
export interface IClientOptions {
|
|
|
|
serverAddress: string
|
|
|
|
}
|
|
|
|
|
2018-03-13 05:15:40 +00:00
|
|
|
export class UniverseClient {
|
2018-03-15 00:05:13 +00:00
|
|
|
public options;
|
2018-03-13 05:15:40 +00:00
|
|
|
|
2018-03-15 00:05:13 +00:00
|
|
|
constructor(optionsArg: IClientOptions) {
|
|
|
|
this.options = optionsArg;
|
|
|
|
}
|
|
|
|
|
2018-03-15 00:16:16 +00:00
|
|
|
public async sendMessage(messageArg, payloadArg) {
|
|
|
|
const requestBody = {
|
|
|
|
message: messageArg,
|
|
|
|
payload: payloadArg
|
|
|
|
}
|
|
|
|
await plugins.smartrequest.post(this.options.serverAddress, {
|
|
|
|
requestBody: requestBody
|
2018-03-15 00:05:13 +00:00
|
|
|
})
|
2018-03-13 05:15:40 +00:00
|
|
|
}
|
|
|
|
|
2018-03-15 00:05:13 +00:00
|
|
|
public getMessageObservable () {
|
2018-03-13 05:15:40 +00:00
|
|
|
|
|
|
|
}
|
2018-03-15 00:05:13 +00:00
|
|
|
}
|