private void writeMethodCall(ByteBuffer buffer, RemoteMethodCallMessage call) throws IOException{
        buffer.putShort((short)call.objectId);
        buffer.putShort(call.methodId);
        buffer.putShort(call.invocationId);
        if (call.args == null){
            buffer.put((byte)0);
        }else{
            buffer.put((byte)call.args.length);

            // Right now it writes 0 for every null argument
            // and 1 for every non-null argument followed by the serialized
            // argument. For the future, using a bit set should be considered.
            for (Object obj : call.args){
                if (obj != null){
                    buffer.put((byte)0x01);
                    Serializer.writeClassAndObject(buffer, obj);
                }else{
                    buffer.put((byte)0x00);
                }
            }
        }
    }
{@link RmiSerializer} is responsible for serializing RMI messages
like define object, call, and return.

@author Kirill Vainer
jme3-networking/src/main/java/com/jme3/network/rmi/RmiSerializer.java