public synchronized void input(JSONObject o) throws ProtocolException, IOException {
	if(!gotHandshake){
	    if(parseHandshake(o)){
		try {
		    JSONObject successMessage = new JSONObject()
			.put("message", "connect").put("status", true);
		    sendMessage(successMessage);
		}
		catch (JSONException e) {}
	    }
	    return;
	}
	else if(!gotLoadout.get()){
	    parseLoadout(o);
	}
	else if(o.has("message")){
	    try {
		if(o.get("message").equals("action")){
		    messages.add(o);
		}
		else {
		    throw new ProtocolException("Unexpected message, got '" + o.get("message")
						+ "' but expected 'action'");
		}
	    }
	    catch (JSONException e){
		throw new ProtocolException("Invalid or incomplete packet: " + e.getMessage());
	    }
	}
	else {
	    try {
		throw new ProtocolException("Unexpected packet: '" + o.get("message") + "'");
	    }
	    catch (JSONException e) {
		throw new ProtocolException("Invalid or incomplete packet");
	    }
	}
    }