Updated the controlled room protocol to fit more needs
This commit is contained in:
parent
cdce17b10b
commit
9506a80b9b
@ -431,14 +431,14 @@ class SyncplayClient(object):
|
||||
self.ui.showMessage("Identifying as room controller with password '{}'...".format(controlPassword))
|
||||
self._protocol.requestControlledRoom(controlPassword)
|
||||
|
||||
def controllerIdentificationError(self):
|
||||
self.ui.showErrorMessage("Failed to identify as a room controller.")
|
||||
def controllerIdentificationError(self, username):
|
||||
self.ui.showErrorMessage("<{}> failed to identify as a room controller.".format(username))
|
||||
|
||||
def controllerIdentificationSuccess(self):
|
||||
def controllerIdentificationSuccess(self, username):
|
||||
# TODO: More UI stuff
|
||||
self.ui.showErrorMessage("Authenticated as a room controller")
|
||||
self.ui.showErrorMessage("<{}> authenticated as a room controller".format(username))
|
||||
|
||||
# TODO: A person authenticated as a room controller
|
||||
# TODO: Mark person as a room controller
|
||||
# TODO: Disable UI's "Create new Controlled Room when in Controlled Room"
|
||||
# TODO: Disable authenticate when authenticated
|
||||
|
||||
|
||||
@ -122,9 +122,9 @@ class SyncClientProtocol(JSONCommandProtocol):
|
||||
self._SetUser(values)
|
||||
elif command == "controllerAuth":
|
||||
if values['success']:
|
||||
self._client.controllerIdentificationSuccess()
|
||||
self._client.controllerIdentificationSuccess(values["user"])
|
||||
else:
|
||||
self._client.controllerIdentificationError()
|
||||
self._client.controllerIdentificationError(values["user"])
|
||||
elif command == "newControlledRoom":
|
||||
controlPassword = values['password']
|
||||
roomName = values['roomName']
|
||||
@ -341,17 +341,17 @@ class SyncServerProtocol(JSONCommandProtocol):
|
||||
}
|
||||
})
|
||||
|
||||
def sendControlledRoomAuthStatus(self, success):
|
||||
def sendControlledRoomAuthStatus(self, success, username):
|
||||
self.sendSet({
|
||||
"controllerAuth": {
|
||||
"user": username,
|
||||
"success": success
|
||||
}
|
||||
})
|
||||
|
||||
def sendUserSetting(self, username, room, file_, event):
|
||||
room = {"name": room.getName()}
|
||||
user = {}
|
||||
user[username] = {}
|
||||
user = {username: {}}
|
||||
user[username]["room"] = room
|
||||
if file_:
|
||||
user[username]["file"] = file_
|
||||
@ -388,7 +388,7 @@ class SyncServerProtocol(JSONCommandProtocol):
|
||||
"paused": paused,
|
||||
"doSeek": doSeek,
|
||||
"setBy": setBy.getName()
|
||||
}
|
||||
}
|
||||
ping = {
|
||||
"latencyCalculation": self._pingService.newTimestamp(),
|
||||
"serverRtt": self._pingService.getRtt()
|
||||
|
||||
@ -110,13 +110,12 @@ class SyncFactory(Factory):
|
||||
room = watcher.getRoom()
|
||||
try:
|
||||
success = RoomPasswordProvider.check(room.getName(), password, self._salt)
|
||||
# TODO: Authenticate watcher to make changes in the room
|
||||
watcher.sendControlledRoomAuthStatus(success)
|
||||
self._roomManager.broadcastRoom(watcher, lambda w: w.sendControlledRoomAuthStatus(success, watcher.getName()))
|
||||
except NotControlledRoom:
|
||||
newName = RoomPasswordProvider.getControlledRoomName(room.getName(), password, self._salt)
|
||||
watcher.sendNewControlledRoom(newName, password)
|
||||
except ValueError:
|
||||
watcher.sendControlledRoomAuthStatus(False)
|
||||
self._roomManager.broadcastRoom(watcher, lambda w: w.sendControlledRoomAuthStatus(False, watcher.getName()))
|
||||
|
||||
|
||||
class RoomManager(object):
|
||||
@ -301,8 +300,8 @@ class Watcher(object):
|
||||
def sendNewControlledRoom(self, roomName, password):
|
||||
self._connector.sendNewControlledRoom(roomName, password)
|
||||
|
||||
def sendControlledRoomAuthStatus(self, success):
|
||||
self._connector.sendControlledRoomAuthStatus(success)
|
||||
def sendControlledRoomAuthStatus(self, success, username):
|
||||
self._connector.sendControlledRoomAuthStatus(success, username)
|
||||
|
||||
def __lt__(self, b):
|
||||
if self.getPosition() is None or self._file is None:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user