<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def publishToRoom(self, roomId, name, data, userList=None):
 """ Publish to given room data submitted """

        if userList is None:
            userList = self.getRoom(roomId)

        # Publish data to all room users
        logging.debug("%s: broadcasting (name: %s, data: %s, number of users: %s)" % (self._gcls(), name, data, len(userList)))
        self.broadcast(userList, {
            "name": name,
            "data": SockJSRoomHandler._parser.encode(data)
        })