MCPcopy Create free account
hub / github.com/codecombat/codecombat / resetWSInfos

Method resetWSInfos

app/lib/wsBus.js:128–151  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

126 }
127
128 async resetWSInfos () {
129 this.wsInfos = {
130 inited: false,
131 friends: {} // role: friends | teacher | student
132 }
133
134 if (me.isAnonymous()) {
135 this.wsInfos.inited = true // anonymous user do not have friends feature
136 } else {
137 console.log('publish user online', me.id)
138 this.ws.publish(this.ws.topicName('user', me.id.toString()), { online: true }) // tell others you're online
139 const friends = me.get('friends') || [] // TODO: to setup true friends feature
140 const friendTopics = []
141 friends.forEach(f => {
142 this.addFriend(f.userId.toString(), { role: f.role })
143 friendTopics.push(`user-${f.userId.toString()}`)
144 })
145 this.ws.subscribe(friendTopics)
146 // const onlineFriends = await me.fetchOnlineFriends() // fetch online friends
147 // this.updateOnlineFriends(onlineFriends)
148 this.wsInfos.inited = true
149 }
150 // console.log('wsInfos reset success')
151 }
152
153 async onMeSynced () {
154 console.log('me synced')

Callers 2

initMethod · 0.95
onMeSyncedMethod · 0.95

Calls 6

addFriendMethod · 0.95
isAnonymousMethod · 0.80
logMethod · 0.80
publishMethod · 0.80
getMethod · 0.45
subscribeMethod · 0.45

Tested by

no test coverage detected