 		self.uuid = uuid
 		self.availableColors = []
 		self.remainingTiles = 0
-		self.lastConnected = Date() //Unused for now
+		self.lastConnected = String() //Unused for now
 		self.ip = ""
 	}
 	
 	func sendJSON(json: JSON) {
 		//TODO: Change serialize() to makeBytes() to save bandwidth
-		try? self.socket.send(json.serialize().makeString())
+		try? self.socket?.send(json.serialize().makeString())
 	}
 	
 	class func randomUUID(length: Int) -> String {

		self.uuid = User.randomUUID(length: 20)
		self.availableColors = []
		self.remainingTiles = 50
		self.lastConnected = Date()
		self.ip = ""
	}
	

func ==(lhs: User, rhs: User) -> Bool {
	return lhs.uuid.hashValue == rhs.uuid.hashValue
}

/*
try row.set("username", username)
try row.set("uuid", uuid)
try row.set("latestIP", ip)
try row.set("remainingTiles", remainingTiles)
try row.set("lastConnected", lastConnected)
try row.set("availableColors", getColorListString(colors: availableColors))
*/

//Database preparation
extension User: Preparation {
	static func prepare(_ database: Database) throws {
		try database.create(self) { users in
			users.id()
			users.string("username")
			users.string("uuid")
			users.string("latestIP")
			users.int("remainingTiles")
			users.string("lastConnected")
			users.string("availableColors")
		}
	}
	
	static func revert(_ database: Database) throws {
		try database.delete(self)
	}
}
