Esempio n. 1
0
	def create(self, channelName, uid, appName, password = None, masterPwd = None, forceJoin=True):
		"""Return: Ajoute un channel a la liste des rooms  -> bool"""

		import random
		from commons.session import Session

		if appName not in self.applications:
			self.applications[appName] = []

		if self.chanExists(channelName=channelName, appName=appName) == False:
			client = Session().get(uid)
			client.room_name = channelName
			channel = Channel(channelName)
			if masterPwd is None:
				channel.master_password = random.getrandbits(16)
			else:
				channel.master_password = masterPwd
			if forceJoin is True:
			    channel.add(uid, channel.master_password)
			if password is not None:
				channel.password = password
			self.applications[appName].append({
				'name': channelName,
				'channel': channel,
				'app': appName
			})
			return True
		#self.applications.pop(appName)
		return False