@hivegpt/hiveai-angular 0.0.157 → 0.0.160
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/hivegpt-hiveai-angular.umd.js +101 -43
- package/bundles/hivegpt-hiveai-angular.umd.js.map +1 -1
- package/bundles/hivegpt-hiveai-angular.umd.min.js +1 -1
- package/bundles/hivegpt-hiveai-angular.umd.min.js.map +1 -1
- package/esm2015/hivegpt-hiveai-angular.js +4 -3
- package/esm2015/lib/components/NotificationSocket.js +29 -0
- package/esm2015/lib/components/chat-drawer/chat-drawer.component.js +19 -14
- package/esm2015/lib/components/conversation.service.js +10 -1
- package/esm2015/lib/components/socket-service.service.js +45 -27
- package/fesm2015/hivegpt-hiveai-angular.js +96 -41
- package/fesm2015/hivegpt-hiveai-angular.js.map +1 -1
- package/hivegpt-hiveai-angular.d.ts +3 -2
- package/hivegpt-hiveai-angular.d.ts.map +1 -1
- package/hivegpt-hiveai-angular.metadata.json +1 -1
- package/lib/components/NotificationSocket.d.ts +5 -0
- package/lib/components/NotificationSocket.d.ts.map +1 -0
- package/lib/components/chat-drawer/chat-drawer.component.d.ts +4 -0
- package/lib/components/chat-drawer/chat-drawer.component.d.ts.map +1 -1
- package/lib/components/conversation.service.d.ts +4 -0
- package/lib/components/conversation.service.d.ts.map +1 -1
- package/lib/components/socket-service.service.d.ts +16 -8
- package/lib/components/socket-service.service.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,42 +1,60 @@
|
|
|
1
1
|
import { Injectable } from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { prod_environment } from '../../environments/environment';
|
|
2
|
+
import { ConversationService } from './conversation.service';
|
|
3
|
+
import { NotificationSocket } from './NotificationSocket';
|
|
5
4
|
import * as i0 from "@angular/core";
|
|
5
|
+
import * as i1 from "./conversation.service";
|
|
6
|
+
import * as i2 from "./NotificationSocket";
|
|
6
7
|
export class SocketService {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.
|
|
8
|
+
constructor(conversationService, notificationSocket) {
|
|
9
|
+
this.conversationService = conversationService;
|
|
10
|
+
this.notificationSocket = notificationSocket;
|
|
11
|
+
this.isCommonSocketInitialized = false;
|
|
12
|
+
this.isUserSpecificSocketInitialized = false;
|
|
13
|
+
this.isUserSpecificEventReleased = true;
|
|
14
|
+
this.messageQueue = [];
|
|
15
|
+
this.releaseInterval = 1000;
|
|
16
|
+
this.intervalSetup = false;
|
|
17
|
+
this.startReleasingMessages();
|
|
9
18
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
19
|
+
isSocketInitialized(isCommon) {
|
|
20
|
+
return isCommon
|
|
21
|
+
? this.isCommonSocketInitialized
|
|
22
|
+
: this.isUserSpecificSocketInitialized &&
|
|
23
|
+
!this.isUserSpecificEventReleased;
|
|
14
24
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// Handle incoming messages
|
|
25
|
+
disconnectSocketConnection() {
|
|
26
|
+
this.notificationSocket.disconnect();
|
|
18
27
|
}
|
|
19
|
-
|
|
20
|
-
this.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.
|
|
28
|
+
registerUserSpecificHiveSocket(botId, conversation_id) {
|
|
29
|
+
this.notificationSocket.emit('joinData', {
|
|
30
|
+
groupId: "Hive_AI_Notifs_" + botId + "_" + conversation_id,
|
|
31
|
+
});
|
|
32
|
+
this.notificationSocket
|
|
33
|
+
.fromEvent('commonNotification')
|
|
34
|
+
.subscribe((res) => {
|
|
35
|
+
this.conversationService.sendValidatedUserData(res);
|
|
36
|
+
});
|
|
24
37
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
|
|
38
|
+
startReleasingMessages() {
|
|
39
|
+
if (!this.intervalSetup) {
|
|
40
|
+
setInterval(() => {
|
|
41
|
+
if (this.messageQueue.length > 0) {
|
|
42
|
+
const message = this.messageQueue.shift(); // Remove the first message from the queue
|
|
43
|
+
// this.campaignService.sendValidatedUserData(message);
|
|
30
44
|
}
|
|
31
|
-
});
|
|
32
|
-
|
|
45
|
+
}, this.releaseInterval);
|
|
46
|
+
this.intervalSetup = true; // Prevents multiple intervals
|
|
47
|
+
}
|
|
33
48
|
}
|
|
34
49
|
}
|
|
35
|
-
SocketService.ɵprov = i0.ɵɵdefineInjectable({ factory: function SocketService_Factory() { return new SocketService(); }, token: SocketService, providedIn: "root" });
|
|
50
|
+
SocketService.ɵprov = i0.ɵɵdefineInjectable({ factory: function SocketService_Factory() { return new SocketService(i0.ɵɵinject(i1.ConversationService), i0.ɵɵinject(i2.NotificationSocket)); }, token: SocketService, providedIn: "root" });
|
|
36
51
|
SocketService.decorators = [
|
|
37
52
|
{ type: Injectable, args: [{
|
|
38
53
|
providedIn: 'root'
|
|
39
54
|
},] }
|
|
40
55
|
];
|
|
41
|
-
SocketService.ctorParameters = () => [
|
|
42
|
-
|
|
56
|
+
SocketService.ctorParameters = () => [
|
|
57
|
+
{ type: ConversationService },
|
|
58
|
+
{ type: NotificationSocket }
|
|
59
|
+
];
|
|
60
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic29ja2V0LXNlcnZpY2Uuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiJEOi9oaXZlR1BULUFJLXBhY2thZ2VzL0hpdmVBSS1QYWNrYWdlcy9wcm9qZWN0cy9oaXZlZ3B0L2V2ZW50c2dwdC1hbmd1bGFyL3NyYy8iLCJzb3VyY2VzIjpbImxpYi9jb21wb25lbnRzL3NvY2tldC1zZXJ2aWNlLnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUszQyxPQUFPLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUM3RCxPQUFPLEVBQUUs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gfSwgdGhpcy5yZWxlYXNlSW50ZXJ2YWwpO1xuICAgICAgdGhpcy5pbnRlcnZhbFNldHVwID0gdHJ1ZTsgLy8gUHJldmVudHMgbXVsdGlwbGUgaW50ZXJ2YWxzXG4gICAgfVxuICB9XG59XG4iXX0=
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HttpHeaders, HttpClient } from '@angular/common/http';
|
|
2
|
-
import { ɵɵdefineInjectable, Injectable, EventEmitter, ElementRef, Component, ChangeDetectionStrategy, ChangeDetectorRef, Renderer2, ViewChild, ViewChildren, Input, Output, Pipe, Inject, NgModule } from '@angular/core';
|
|
2
|
+
import { ɵɵdefineInjectable, Injectable, ɵɵinject, EventEmitter, ElementRef, Component, ChangeDetectionStrategy, ChangeDetectorRef, Renderer2, ViewChild, ViewChildren, Input, Output, Pipe, Inject, NgModule } from '@angular/core';
|
|
3
3
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
4
|
-
import {
|
|
4
|
+
import { Subject, of } from 'rxjs';
|
|
5
5
|
import { switchMap, catchError } from 'rxjs/operators';
|
|
6
|
-
import {
|
|
6
|
+
import { Socket } from 'ngx-socket-io';
|
|
7
7
|
import { DOCUMENT, CommonModule } from '@angular/common';
|
|
8
8
|
import { FormsModule } from '@angular/forms';
|
|
9
9
|
import { MatIconModule } from '@angular/material/icon';
|
|
@@ -62,6 +62,7 @@ const dev_environment = {
|
|
|
62
62
|
class ConversationService {
|
|
63
63
|
constructor() {
|
|
64
64
|
this.storageKey = 'conversationKey';
|
|
65
|
+
this.userSepecificNotification = new Subject();
|
|
65
66
|
}
|
|
66
67
|
generateKey() {
|
|
67
68
|
const timestamp = Math.floor(new Date().getTime() / 1000).toString(16);
|
|
@@ -84,6 +85,13 @@ class ConversationService {
|
|
|
84
85
|
this.ensureKeyExists(storageKey, key);
|
|
85
86
|
return localStorage.getItem(storageKey);
|
|
86
87
|
}
|
|
88
|
+
sendValidatedUserData(message) {
|
|
89
|
+
//console.log('lgging messages', message, new Date());\
|
|
90
|
+
this.userSepecificNotification.next(message);
|
|
91
|
+
}
|
|
92
|
+
getUserSpecificNotification() {
|
|
93
|
+
return this.userSepecificNotification.asObservable();
|
|
94
|
+
}
|
|
87
95
|
}
|
|
88
96
|
ConversationService.ɵprov = ɵɵdefineInjectable({ factory: function ConversationService_Factory() { return new ConversationService(); }, token: ConversationService, providedIn: "root" });
|
|
89
97
|
ConversationService.decorators = [
|
|
@@ -93,42 +101,84 @@ ConversationService.decorators = [
|
|
|
93
101
|
];
|
|
94
102
|
ConversationService.ctorParameters = () => [];
|
|
95
103
|
|
|
96
|
-
class
|
|
104
|
+
class NotificationSocket extends Socket {
|
|
97
105
|
constructor() {
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
connect() {
|
|
101
|
-
const url = prod_environment;
|
|
102
|
-
this.socket$ = webSocket(url.SocketUrl);
|
|
103
|
-
this.socket$.subscribe((message) => this.onMessage(message), (err) => console.error('WebSocket error', err), () => console.warn('WebSocket closed'));
|
|
106
|
+
super(socketConfig);
|
|
104
107
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
}
|
|
109
|
+
NotificationSocket.ɵprov = ɵɵdefineInjectable({ factory: function NotificationSocket_Factory() { return new NotificationSocket(); }, token: NotificationSocket, providedIn: "root" });
|
|
110
|
+
NotificationSocket.decorators = [
|
|
111
|
+
{ type: Injectable, args: [{
|
|
112
|
+
providedIn: 'root' // This ensures the service is available across the application
|
|
113
|
+
},] }
|
|
114
|
+
];
|
|
115
|
+
NotificationSocket.ctorParameters = () => [];
|
|
116
|
+
const socketConfig = {
|
|
117
|
+
url: prod_environment.SocketUrl,
|
|
118
|
+
options: {
|
|
119
|
+
transports: ['websocket', 'polling'],
|
|
120
|
+
reconnection: true,
|
|
121
|
+
autoConnect: true,
|
|
122
|
+
upgrade: true,
|
|
123
|
+
reconnectionDelay: 1000,
|
|
124
|
+
reconnectionDelayMax: 5000,
|
|
125
|
+
reconnectionAttempts: Infinity
|
|
111
126
|
}
|
|
112
|
-
|
|
113
|
-
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
class SocketService {
|
|
130
|
+
constructor(conversationService, notificationSocket) {
|
|
131
|
+
this.conversationService = conversationService;
|
|
132
|
+
this.notificationSocket = notificationSocket;
|
|
133
|
+
this.isCommonSocketInitialized = false;
|
|
134
|
+
this.isUserSpecificSocketInitialized = false;
|
|
135
|
+
this.isUserSpecificEventReleased = true;
|
|
136
|
+
this.messageQueue = [];
|
|
137
|
+
this.releaseInterval = 1000;
|
|
138
|
+
this.intervalSetup = false;
|
|
139
|
+
this.startReleasingMessages();
|
|
140
|
+
}
|
|
141
|
+
isSocketInitialized(isCommon) {
|
|
142
|
+
return isCommon
|
|
143
|
+
? this.isCommonSocketInitialized
|
|
144
|
+
: this.isUserSpecificSocketInitialized &&
|
|
145
|
+
!this.isUserSpecificEventReleased;
|
|
146
|
+
}
|
|
147
|
+
disconnectSocketConnection() {
|
|
148
|
+
this.notificationSocket.disconnect();
|
|
149
|
+
}
|
|
150
|
+
registerUserSpecificHiveSocket(botId, conversation_id) {
|
|
151
|
+
this.notificationSocket.emit('joinData', {
|
|
152
|
+
groupId: "Hive_AI_Notifs_" + botId + "_" + conversation_id,
|
|
153
|
+
});
|
|
154
|
+
this.notificationSocket
|
|
155
|
+
.fromEvent('commonNotification')
|
|
156
|
+
.subscribe((res) => {
|
|
157
|
+
this.conversationService.sendValidatedUserData(res);
|
|
158
|
+
});
|
|
114
159
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (
|
|
119
|
-
|
|
160
|
+
startReleasingMessages() {
|
|
161
|
+
if (!this.intervalSetup) {
|
|
162
|
+
setInterval(() => {
|
|
163
|
+
if (this.messageQueue.length > 0) {
|
|
164
|
+
const message = this.messageQueue.shift(); // Remove the first message from the queue
|
|
165
|
+
// this.campaignService.sendValidatedUserData(message);
|
|
120
166
|
}
|
|
121
|
-
});
|
|
122
|
-
|
|
167
|
+
}, this.releaseInterval);
|
|
168
|
+
this.intervalSetup = true; // Prevents multiple intervals
|
|
169
|
+
}
|
|
123
170
|
}
|
|
124
171
|
}
|
|
125
|
-
SocketService.ɵprov = ɵɵdefineInjectable({ factory: function SocketService_Factory() { return new SocketService(); }, token: SocketService, providedIn: "root" });
|
|
172
|
+
SocketService.ɵprov = ɵɵdefineInjectable({ factory: function SocketService_Factory() { return new SocketService(ɵɵinject(ConversationService), ɵɵinject(NotificationSocket)); }, token: SocketService, providedIn: "root" });
|
|
126
173
|
SocketService.decorators = [
|
|
127
174
|
{ type: Injectable, args: [{
|
|
128
175
|
providedIn: 'root'
|
|
129
176
|
},] }
|
|
130
177
|
];
|
|
131
|
-
SocketService.ctorParameters = () => [
|
|
178
|
+
SocketService.ctorParameters = () => [
|
|
179
|
+
{ type: ConversationService },
|
|
180
|
+
{ type: NotificationSocket }
|
|
181
|
+
];
|
|
132
182
|
|
|
133
183
|
// import { Platform } from '@angular/cdk/platform';
|
|
134
184
|
class ChatDrawerComponent {
|
|
@@ -262,20 +312,25 @@ class ChatDrawerComponent {
|
|
|
262
312
|
this.fetchAgents();
|
|
263
313
|
this.cdr.markForCheck();
|
|
264
314
|
this.initializeSocketAndListen();
|
|
315
|
+
setTimeout(() => {
|
|
316
|
+
this.listenSockets();
|
|
317
|
+
}, 200);
|
|
318
|
+
}
|
|
319
|
+
initializeSocket() {
|
|
320
|
+
this.socketService.registerUserSpecificHiveSocket(this.botId, this.conversationKey);
|
|
321
|
+
}
|
|
322
|
+
listenSockets() {
|
|
323
|
+
this.eventSubscription = this.conversation
|
|
324
|
+
.getUserSpecificNotification()
|
|
325
|
+
.subscribe((res) => {
|
|
326
|
+
console.log("Socket Data");
|
|
327
|
+
console.log(res);
|
|
328
|
+
}, (err) => {
|
|
329
|
+
this.eventSubscription.unsubscribe();
|
|
330
|
+
console.error('Error in fetching data from socket');
|
|
331
|
+
});
|
|
265
332
|
}
|
|
266
333
|
initializeSocketAndListen() {
|
|
267
|
-
this.eventSubscription = this.socketService.onEvent('webresult').subscribe((data) => {
|
|
268
|
-
console.log('Event received webresult:', data);
|
|
269
|
-
this.handleEvent(data, 'webresult');
|
|
270
|
-
});
|
|
271
|
-
this.eventSubscription = this.socketService.onEvent('answer').subscribe((data) => {
|
|
272
|
-
console.log('Event received answer:', data);
|
|
273
|
-
this.handleEvent(data, 'answer');
|
|
274
|
-
});
|
|
275
|
-
this.eventSubscription = this.socketService.onEvent('graph').subscribe((data) => {
|
|
276
|
-
console.log('Event received graph:', data);
|
|
277
|
-
this.handleEvent(data, 'graph');
|
|
278
|
-
});
|
|
279
334
|
}
|
|
280
335
|
handleEvent(data, type) {
|
|
281
336
|
switch (type) {
|
|
@@ -293,7 +348,7 @@ class ChatDrawerComponent {
|
|
|
293
348
|
if (this.eventSubscription) {
|
|
294
349
|
this.eventSubscription.unsubscribe();
|
|
295
350
|
}
|
|
296
|
-
this.socketService.close();
|
|
351
|
+
//this.socketService.close();
|
|
297
352
|
}
|
|
298
353
|
changeTemperature(newTemperature) {
|
|
299
354
|
if (this.loading)
|
|
@@ -1381,5 +1436,5 @@ HiveGptModule.decorators = [
|
|
|
1381
1436
|
* Generated bundle index. Do not edit.
|
|
1382
1437
|
*/
|
|
1383
1438
|
|
|
1384
|
-
export { ChatBotComponent, ChatDrawerComponent, HiveGptModule, SocketService as ɵa, ConversationService as ɵb,
|
|
1439
|
+
export { ChatBotComponent, ChatDrawerComponent, HiveGptModule, SocketService as ɵa, ConversationService as ɵb, NotificationSocket as ɵc, VideoPlayerComponent as ɵd, SafeHtmlPipe as ɵe };
|
|
1385
1440
|
//# sourceMappingURL=hivegpt-hiveai-angular.js.map
|