|
|
|
@ -10,6 +10,7 @@ import * as path from 'path';
|
|
|
|
|
export class AnalyticsService { |
|
|
|
|
|
|
|
|
|
private _requester: any; |
|
|
|
|
private _ready: boolean = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(private _onResponse: (response: any) => void) { |
|
|
|
@ -17,6 +18,9 @@ export class AnalyticsService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async sendTask(msgObj: any): Promise<void> { |
|
|
|
|
if(!this._ready) { |
|
|
|
|
return Promise.reject("Analytics is not ready"); |
|
|
|
|
} |
|
|
|
|
let message = JSON.stringify(msgObj); |
|
|
|
|
return this.sendMessage(message); |
|
|
|
|
} |
|
|
|
@ -38,6 +42,8 @@ export class AnalyticsService {
|
|
|
|
|
this._requester.close(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public get ready() { return this._ready; } |
|
|
|
|
|
|
|
|
|
private async _initConnection() { |
|
|
|
|
this._requester = zmq.socket('pair'); |
|
|
|
|
|
|
|
|
@ -55,6 +61,8 @@ export class AnalyticsService {
|
|
|
|
|
|
|
|
|
|
this._requester.on("message", this._onAnalyticsMessage.bind(this)); |
|
|
|
|
|
|
|
|
|
this._ready = true; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private async _connectToAnalytics() { |
|
|
|
|