|
|
@@ -13,8 +13,9 @@ 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
|
16
|
/**
|
|
|
17
|
+ *
|
|
|
18
|
+ *
|
|
18
|
19
|
* Breaking out as much pubnub specific flavor
|
|
19
|
20
|
*/
|
|
20
|
21
|
const setupPubnub = async uuid => {
|
|
|
@@ -37,15 +38,10 @@ const setupPubnub = async uuid => {
|
|
37
|
38
|
}
|
|
38
|
39
|
|
|
39
|
40
|
class ChatMessage {
|
|
40
|
|
- constructor({ title, description }) {
|
|
41
|
|
- ;(this.title = title), (this.description = description)
|
|
|
41
|
+ constructor(message) {
|
|
|
42
|
+ this.description = message
|
|
42
|
43
|
}
|
|
43
|
44
|
}
|
|
44
|
|
-
|
|
45
|
|
-const testMessage = new ChatMessage({
|
|
46
|
|
- title: 'testing',
|
|
47
|
|
- description: 'hello world!',
|
|
48
|
|
-})
|
|
49
|
45
|
const MAIN_CHANNEL = 'Channel-Siimee'
|
|
50
|
46
|
|
|
51
|
47
|
/** Singleton that holds all our chat information */
|
|
|
@@ -101,7 +97,10 @@ class Chatter {
|
|
101
|
97
|
*/
|
|
102
|
98
|
async publish(channel, message) {
|
|
103
|
99
|
// console.log('publishing message to channel:', channel)
|
|
104
|
|
- return providerMethods.publish({ channel, message })
|
|
|
100
|
+ return providerMethods.publish({
|
|
|
101
|
+ channel,
|
|
|
102
|
+ message: new ChatMessage(message)
|
|
|
103
|
+ })
|
|
105
|
104
|
}
|
|
106
|
105
|
/**
|
|
107
|
106
|
* Subscribe to a channels
|
|
|
@@ -129,6 +128,7 @@ class Chatter {
|
|
129
|
128
|
this.subscriptions = [MAIN_CHANNEL]
|
|
130
|
129
|
console.warn('chatter stop no implemented')
|
|
131
|
130
|
}
|
|
|
131
|
+
|
|
132
|
132
|
}
|
|
133
|
133
|
|
|
134
|
134
|
export { Chatter }
|