-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7708 from Tainan404/fix-user-leaving
Add ping-pong message to html5 client
- Loading branch information
Showing
14 changed files
with
125 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
|
||
const PingPong = new Mongo.Collection('ping-pong'); | ||
|
||
export default PingPong; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './publishers'; | ||
import './methods'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import ping from './methods/ping'; | ||
|
||
Meteor.methods({ | ||
ping, | ||
}); |
21 changes: 21 additions & 0 deletions
21
bigbluebutton-html5/imports/api/ping-pong/server/methods/ping.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import { check } from 'meteor/check'; | ||
import Users from '/imports/api/users'; | ||
|
||
export default function ping(credentials) { | ||
const { meetingId, requesterUserId, requesterToken } = credentials; | ||
|
||
check(meetingId, String); | ||
check(requesterUserId, String); | ||
check(requesterToken, String); | ||
|
||
|
||
return Users.upsert({ | ||
meetingId, | ||
userId: requesterUserId, | ||
}, { | ||
$set: { | ||
lastPing: Date.now(), | ||
}, | ||
}); | ||
} |
33 changes: 33 additions & 0 deletions
33
bigbluebutton-html5/imports/api/ping-pong/server/publishers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import Logger from '/imports/startup/server/logger'; | ||
import _ from 'lodash'; | ||
|
||
const COLLECTION_NAME = 'ping-pong'; | ||
const POLL_INTERVAL = 5000; | ||
|
||
function pingPong(credentials) { | ||
const { meetingId, requesterUserId } = credentials; | ||
const id = _.uniqueId('pong-'); | ||
Logger.info(`Starting ping-pong publish for userId: ${requesterUserId}`); | ||
const pongSender = (interval) => { | ||
const payload = { | ||
pong: { | ||
message: 'pong', | ||
time: Date.now(), | ||
meetingId, | ||
}, | ||
}; | ||
let fn = this.added.bind(this); | ||
if (interval) fn = this.changed.bind(this); | ||
fn(COLLECTION_NAME, id, payload); | ||
}; | ||
pongSender(); | ||
this.ready(); | ||
const interval = Meteor.setInterval(() => pongSender(true), POLL_INTERVAL); | ||
|
||
this.onStop(() => { | ||
Meteor.clearInterval(interval); | ||
}); | ||
} | ||
|
||
Meteor.publish('ping-pong', pingPong); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
bigbluebutton-html5/imports/ui/components/ping-pong/container.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react'; | ||
import { withTracker } from 'meteor/react-meteor-data'; | ||
import PingPong from '/imports/api/ping-pong'; | ||
import { makeCall } from '/imports/ui/services/api'; | ||
|
||
class PlaceHolderComponent extends React.Component { | ||
shouldComponentUpdate() { | ||
return false; | ||
} | ||
|
||
render() { | ||
return null; | ||
} | ||
} | ||
|
||
export default withTracker(() => { | ||
PingPong.find({}).observe({ | ||
added: () => makeCall('ping'), | ||
changed: () => makeCall('ping'), | ||
}); | ||
return {}; | ||
})(PlaceHolderComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters