public Message parseMessage(String s) {
		//System.out.println(s);
		JSONObject data;
		JSONArray argdata;
		String[] args;
		
		try {
			data = new JSONObject(s);
			switch(data.getInt("type")) {
				case Message.TYPE_CHAT:
					return new STDMessage(this, data.getString("payload"));
				case Message.TYPE_USER:
					argdata = data.getJSONArray("args");
					args = new String[10];
					for (int i = 0; i < argdata.length(); i++) args[i] = argdata.getString(i);
					return new UserMessage(this, data.getString("action"), args);
				case Message.TYPE_CHANNEL:
					argdata = data.getJSONArray("args");
					args = new String[10];
					for (int i = 0; i < argdata.length(); i++) args[i] = argdata.getString(i);
					return new ChannelMessage(this, data.getString("action"), args);
				case Message.TYPE_SERVER:
					argdata = data.getJSONArray("args");
					args = new String[10];
					for (int i = 0; i < argdata.length(); i++) args[i] = argdata.getString(i);
					return new ServerMessage(this, data.getString("action"), args);
				case Message.TYPE_AUTH:
					return new AuthMessage(this, data.get("payload"));
			}
			//this.channel.broadcast(data.getString("payload"));
		}
		catch (JSONException e) {
			System.out.println("Corrupted data was received from client");
		}
		
		return null;
	}