示例#1
0
 def findFreeUsername(self, username):
     username = truncateText(username,constants.MAX_USERNAME_LENGTH)
     allnames = []
     for room in self._rooms.itervalues():
         for watcher in room.getWatchers():
             allnames.append(watcher.getName().lower())
     while username.lower() in allnames:
         username += '_'
     return username
示例#2
0
    def setWatcherRoom(self, watcher, roomName, asJoin=False):
        roomName = truncateText(roomName, constants.MAX_ROOM_NAME_LENGTH)
        self._roomManager.moveWatcher(watcher, roomName)
        if asJoin:
            self.sendJoinMessage(watcher)
        else:
            self.sendRoomSwitchMessage(watcher)

        room = watcher.getRoom()
        roomSetByName = room.getSetBy().getName() if room.getSetBy() else None
        watcher.setPlaylist(roomSetByName, room.getPlaylist())
        watcher.setPlaylistIndex(roomSetByName, room.getPlaylistIndex())
        if RoomPasswordProvider.isControlledRoom(roomName):
            for controller in room.getControllers():
                watcher.sendControlledRoomAuthStatus(True, controller, roomName)
示例#3
0
 def loadRooms(self, rooms):
     roomsLoaded = []
     for roomDetails in rooms:
         roomName = truncateText(roomDetails[0],
                                 constants.MAX_ROOM_NAME_LENGTH)
         room = Room(roomDetails[0], self._roomsDbHandle)
         room.loadRoom(roomDetails)
         if roomName in self._permanentRooms:
             room.setPermanent(True)
         self._rooms[roomName] = room
         roomsLoaded.append(roomName)
     for roomName in self._permanentRooms:
         if roomName not in roomsLoaded:
             roomDetails = (roomName, "", 0, 0, 0)
             room = Room(roomName, self._roomsDbHandle)
             room.loadRoom(roomDetails)
             room.setPermanent(True)
             self._rooms[roomName] = room
示例#4
0
 def addWatcher(self, watcherProtocol, username, roomName):
     roomName = truncateText(roomName, constants.MAX_ROOM_NAME_LENGTH)
     username = self._roomManager.findFreeUsername(username)
     watcher = Watcher(self, watcherProtocol, username)
     self.setWatcherRoom(watcher, roomName, asJoin=True)
示例#5
0
 def setFile(self, file_):
     print file_
     if file_ and file_.has_key("name"):
         file_["name"] = truncateText(file_["name"],constants.MAX_FILENAME_LENGTH)
     self._file = file_
     self._server.sendFileUpdate(self)
示例#6
0
 def moveWatcher(self, watcher, roomName):
     roomName = truncateText(roomName, constants.MAX_ROOM_NAME_LENGTH)
     self.removeWatcher(watcher)
     room = self._getRoom(roomName)
     room.addWatcher(watcher)
示例#7
0
 def sendChat(self,watcher,message):
     message = truncateText(message, constants.MAX_CHAT_MESSAGE_LENGTH)
     messageDict={"message":message,"username" : watcher.getName()}
     self._roomManager.broadcastRoom(watcher, lambda w: w.sendChatMessage(messageDict))
示例#8
0
 def setFile(self, file_):
     if file_ and "name" in file_:
         file_["name"] = truncateText(file_["name"],
                                      constants.MAX_FILENAME_LENGTH)
     self._file = file_
     self._server.sendFileUpdate(self)
示例#9
0
 def sendChat(self, watcher, message):
     message = truncateText(message, self.maxChatMessageLength)
     messageDict = {"message": message, "username": watcher.getName()}
     self._roomManager.broadcastRoom(
         watcher, lambda w: w.sendChatMessage(messageDict))
示例#10
0
 def setFile(self, file_):
     if file_ and "name" in file_:
         file_["name"] = truncateText(file_["name"], constants.MAX_FILENAME_LENGTH)
     self._file = file_
     self._server.sendFileUpdate(self)
示例#11
0
 def sendChat(self, watcher, message):
     message = truncateText(message, self.maxChatMessageLength)
     messageDict = {"message": message, "username": watcher.getName()}
     self._roomManager.broadcastRoom(watcher, lambda w: w.sendChatMessage(messageDict))