@steedos/service-core-objects 3.0.0-beta.44 → 3.0.0-beta.46

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.
@@ -1,16 +1,48 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2
+ const SocketCommands = {
3
+ subscribe: "subscribe",
4
+ unsubscribe:"unsubscribe"
5
+ }
6
+
7
+ const SocketEvents = {
8
+ metadataChange: 's:metadata:change',
9
+ notificationChange: 's:notification-change'
10
+ }
11
+
12
+ const SocketRoomParts = {
13
+ space: 'space',
14
+ me: 'me',
15
+ notificationChange: 'notification-change'
16
+ }
17
+
1
18
  // 连接到服务器
2
- const socket = window.io("http://192.168.3.59:6900", {
19
+ const socket = window.io("/", {
3
20
  path: "/socket.io"
4
21
  });
5
22
 
6
23
  // 监听连接事件
7
- socket.on("connect", () => {
8
- console.log("Connected to server!");
9
- });
24
+ socket.on("connect", () => {});
25
+
26
+ socket.on("connection-init", ()=>{
27
+ console.log('emit', SocketCommands.subscribe, SocketRoomParts.space);
28
+ socket.emit(SocketCommands.subscribe, {
29
+ roomParts: SocketRoomParts.space
30
+ });
31
+ console.log('emit', SocketCommands.subscribe, SocketRoomParts.me);
32
+ socket.emit(SocketCommands.subscribe, {
33
+ roomParts: SocketRoomParts.me,
34
+ individual: true
35
+ });
36
+
37
+ console.log('emit', SocketCommands.subscribe, SocketRoomParts.notificationChange);
38
+ socket.emit(SocketCommands.subscribe, {
39
+ roomParts: SocketRoomParts.notificationChange,
40
+ individual: true
41
+ });
42
+ })
10
43
 
11
44
  // 监听自定义事件(根据服务器提供的接口)
12
- socket.on("metadata:change", (data) => {
13
- console.log("Received:", data);
45
+ socket.on(SocketEvents.metadataChange, (data) => {
14
46
  if(data.type === 'apps'){
15
47
  window.$(`.btn-reload-global-header-${data.name}`).trigger('click');
16
48
  window.$(`.btn-reload-app-menu-${data.name}`).trigger('click');
@@ -32,8 +64,19 @@ socket.on("metadata:change", (data) => {
32
64
  }
33
65
  });
34
66
 
35
- // 发送消息
36
- socket.emit("event", { key: "value" });
67
+ socket.on(SocketEvents.notificationChange, (data)=>{
68
+ if(data.message){
69
+ window.SteedosUI.notification.open({
70
+ message: data.message.name,
71
+ description: data.message.body
72
+ })
73
+ }
74
+ window.$('.btn-reload-global-header-notifications').trigger('click');
75
+ })
76
+
77
+ socket.on("connect_error", (err) => {
78
+ console.log("连接错误:", err);
79
+ });
37
80
 
38
81
  // 断开连接时
39
82
  socket.on("disconnect", () => {
@@ -105,8 +105,9 @@ module.exports = {
105
105
  this.broker.emit(`notifications.hasBeenSent`, {
106
106
  ids: notifications_ids
107
107
  });
108
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
109
- } catch (Exception) { /* empty */ }
108
+ await ctx.broker.call('b6-microservice.broadcast', {name: '$notification.users', data: {tenantId: message.space, users: to, message: {name: message.name, body: message.body}}})
109
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
110
+ } catch (e) { console.log(e) }
110
111
  }
111
112
  },
112
113
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/service-core-objects",
3
- "version": "3.0.0-beta.44",
3
+ "version": "3.0.0-beta.46",
4
4
  "main": "package.service.js",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -10,12 +10,12 @@
10
10
  "steedos"
11
11
  ],
12
12
  "dependencies": {
13
- "@steedos/service-package-loader": "3.0.0-beta.44",
13
+ "@steedos/service-package-loader": "3.0.0-beta.46",
14
14
  "json2xls": "^0.1.2",
15
15
  "lodash": "^4.17.21"
16
16
  },
17
17
  "description": "steedos package",
18
18
  "repository": {},
19
19
  "license": "MIT",
20
- "gitHead": "a371a63daedb5fcb051643cdfbf73e104e1b5f62"
20
+ "gitHead": "f015256a81bfd6079385d0d1fc6fe896e6cf29ef"
21
21
  }