 		powerLevel: @powerLevel
 		auth: @auth
 
-class Group
-	constructor: (@id, member, passphrase) ->
-		@members = member or []
+class Group extends KcIdentifier
+	constructor: (id, @members = [], passphrase) ->
+		super id
 		@passphrase = if passphrase? \
 			then passphrase else \
 			(String.fromCharCode(Math.floor(Math.random() * \
-			(Options.phRand[1] - Options.phRand[0])) + Options.phRand[0]) for _ in [0..Options.phLength]).join ''
+			(Options.phRand[1] - Options.phRand[0])) + Options.phRand[0]) for _ in [1..Options.phLength]).join ''
 
-	addUser: (user) ->
-		@members.push user
-		loggedUsers.push @id
-
-	removeUser: (user) -> @members.push user
+	addUser: (user) -> @members.push user
+	removeUser: (user) -> @members.pop user
 	toString: () -> "[Group id=#{@id} length-of-members=#{@members.length}]"
 
 	send: (msg) ->

	admin: 50
	owner: 2000

class User
	constructor: (@id, @powerLevel, @auth) ->
		@connection = null
		@cipher = Modules.aes.createCipher @auth

	isQualifiedFor: (powerLevel) -> powerLevel <= @powerLevel
	toString: () -> "[User id=#{@id} powerLevel=#{@powerLevel}]"
	onConnect: (webSocketConnection) -> @connection = webSocketConnection
	onDisconnect: () -> @connection = null if @connection?
	authenticate: (pwd) -> Modules.sha pwd is @auth



userRegistry = []
groupRegistry = []
messageRegistry = []
loggedUsers = []
hostBlacklist = JSON.parse Modules.fs.readFileSync ResourceDir + "blacklist.json"

