|
|
@@ -13,18 +13,6 @@ const providerMethods = {
|
|
13
|
13
|
subscribe: () => console.error('no provider subscribe method set'),
|
|
14
|
14
|
listen: () => console.error('no provider listen method set'),
|
|
15
|
15
|
}
|
|
16
|
|
-
|
|
17
|
|
-/**
|
|
18
|
|
- * Message factory
|
|
19
|
|
- * simple message object creator
|
|
20
|
|
- * to notify the frontend ui of a new message
|
|
21
|
|
- */
|
|
22
|
|
-const messageFactory = {
|
|
23
|
|
- success: () => console.log('notification for successful sent message'),
|
|
24
|
|
- received: (e) => console.log('notification for received message', e.message),
|
|
25
|
|
- error: () => console.log('notification for failed message'),
|
|
26
|
|
-}
|
|
27
|
|
-
|
|
28
|
16
|
/**
|
|
29
|
17
|
*
|
|
30
|
18
|
*
|
|
|
@@ -49,16 +37,11 @@ const setupPubnub = async uuid => {
|
|
49
|
37
|
return pubnubClient
|
|
50
|
38
|
}
|
|
51
|
39
|
|
|
52
|
|
-// class ChatMessage {
|
|
53
|
|
-// constructor({ title, description }) {
|
|
54
|
|
-// ;(this.title = title), (this.description = description)
|
|
55
|
|
-// }
|
|
56
|
|
-// }
|
|
57
|
|
-
|
|
58
|
|
-// const testMessage = new ChatMessage({
|
|
59
|
|
-// title: 'testing',
|
|
60
|
|
-// description: 'hello world!',
|
|
61
|
|
-// })
|
|
|
40
|
+class ChatMessage {
|
|
|
41
|
+ constructor(message) {
|
|
|
42
|
+ this.description = message
|
|
|
43
|
+ }
|
|
|
44
|
+}
|
|
62
|
45
|
const MAIN_CHANNEL = 'Channel-Siimee'
|
|
63
|
46
|
|
|
64
|
47
|
/** Singleton that holds all our chat information */
|
|
|
@@ -114,7 +97,10 @@ class Chatter {
|
|
114
|
97
|
*/
|
|
115
|
98
|
async publish(channel, message) {
|
|
116
|
99
|
// console.log('publishing message to channel:', channel)
|
|
117
|
|
- return providerMethods.publish({ channel, message })
|
|
|
100
|
+ return providerMethods.publish({
|
|
|
101
|
+ channel,
|
|
|
102
|
+ message: new ChatMessage(message)
|
|
|
103
|
+ })
|
|
118
|
104
|
}
|
|
119
|
105
|
/**
|
|
120
|
106
|
* Subscribe to a channels
|