1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 10:39:25 +02:00

Invite/kick now uses transactions so that you can know whether the device actually joined or not. It's a bit messy right now, should introduce some sugar to make it cleaner.

This commit is contained in:
Simo Kinnunen 2014-02-26 19:03:11 +09:00
parent b177d198b3
commit be9d1c9579
3 changed files with 116 additions and 37 deletions

View file

@ -275,29 +275,6 @@ module.exports = function(options) {
new Promise(function(resolve, reject) {
socket.on('disconnect', resolve)
// Grouping
.on('group.invite', function(data) {
push.send([
wireutil.global
, wireutil.envelope(new wire.GroupMessage(
new wire.OwnerMessage(
user.email
, user.name
, user.group
)
, options.groupTimeout
, wireutil.toDeviceRequirements(data)
))
])
})
.on('group.kick', function(data) {
push.send([
user.group
, wireutil.envelope(new wire.UngroupMessage(
wireutil.toDeviceRequirements(data)
))
])
})
// Touch events
.on('input.touchDown', createTouchHandler(wire.TouchDownMessage))
.on('input.touchMove', createTouchHandler(wire.TouchMoveMessage))
@ -316,6 +293,36 @@ module.exports = function(options) {
])
})
// Transactions
.on('group.invite', function(channel, responseChannel, data) {
joinChannel(responseChannel)
push.send([
channel
, wireutil.transaction(
responseChannel
, new wire.GroupMessage(
new wire.OwnerMessage(
user.email
, user.name
, user.group
)
, options.groupTimeout
, wireutil.toDeviceRequirements(data)
)
)
])
})
.on('group.kick', function(channel, responseChannel, data) {
joinChannel(responseChannel)
push.send([
channel
, wireutil.transaction(
responseChannel
, new wire.UngroupMessage(
wireutil.toDeviceRequirements(data)
)
)
])
})
.on('tx.cleanup', function(channel) {
leaveChannel(channel)
})