Package org.gwtnode.core.node.buffer

Examples of org.gwtnode.core.node.buffer.Buffer


                gwtCodeSocket = Socket.create();
                gwtCodeSocket.connect(gwtCodePort, gwtCodeHost);
                proxySocket.onData(new StringOrBufferEventHandler() {
                    @Override
                    protected void onEvent() {
                        Buffer buffer = getBuffer();
                        proxyStream.append(buffer);
                        Message message;
                        do {
                            message = logMessage(proxyStream, true);
                            if (message != null) {
                                gwtCodeSocket.write(message.toBuffer());
                            }
                        } while (message != null);
                        //gwtCodeSocket.write(buffer);
                    }
                });
                gwtCodeSocket.onData(new StringOrBufferEventHandler() {
                    @Override
                    protected void onEvent() {
                        Buffer buffer = getBuffer();
                        gwtCodeStream.append(buffer);
                        Message message;
                        do {
                            message = logMessage(gwtCodeStream, false);
                            if (message != null) {
View Full Code Here


    }
    public void sendMessage(Message message) {
        if (session.getLog().isDebugEnabled()) {
            session.getLog().debug("Sending message: %s", message.toString());
        }
        Buffer buffer = message.toBuffer();
        socket.write(buffer);
    }
View Full Code Here

   
    public void sendMessage(Message message, MessageCallback callback) {
        if (session.getLog().isDebugEnabled()) {
            session.getLog().debug("Sending message: %s", message.toString());
        }
        Buffer buffer = message.toBuffer();
        socket.write(buffer);
        nextMessageCallback = callback;
    }
View Full Code Here

   
    public void sendMessage(InvokeFromClientMessage message, ReturnMessageCallback callback) {
        if (session.getLog().isDebugEnabled()) {
            session.getLog().debug("Sending message: %s", message.toString());
        }
        Buffer buffer = message.toBuffer();
        socket.write(buffer);
        returnMessageCallbacks.push(callback);
    }
View Full Code Here

        objects.add(object);
        return this;
    }
   
    public Buffer toBuffer() {
        Buffer buffer = Buffer.create(length);
        int offset = 0;
        for (Object object : objects) {
            if (object.getClass() == Boolean.class || "boolean".equals(object.getClass().getName())) {
                buffer.set(offset, (byte) (((Boolean) object) ? 1 : 0));
                offset++;
            } else if (object.getClass() == Byte.class || "byte".equals(object.getClass().getName())) {
                buffer.set(offset, (Byte) object);
                offset++;
            } else if (object.getClass() == Character.class || "char".equals(object.getClass().getName())) {
                buffer.writeInt16BE((short) ((Character) object).charValue(), offset);
                offset += 2;
            } else if (object.getClass() == Short.class || "short".equals(object.getClass().getName())) {
                buffer.writeInt16BE((Short) object, offset);
                offset += 2;
            } else if (object.getClass() == Integer.class || "int".equals(object.getClass().getName())) {
                buffer.writeInt32BE((Integer) object, offset);
                offset += 4;
            } else if (object.getClass() == Float.class || "float".equals(object.getClass().getName())) {
                buffer.writeFloatBE((Float) object, offset);
                offset += 4;
            } else if (object.getClass() == Double.class || "double".equals(object.getClass().getName())) {
                buffer.writeDoubleBE((Double) object, offset);
                offset += 8;
            } else if (object.getClass() == String.class) {
                buffer.writeInt32BE(Buffer.byteLength((String) object), offset);
                buffer.write((String) object, offset + 4);
                offset += BufferStream.getStringByteLength((String) object);
            } else if (object instanceof Enum) {
                buffer.set(offset, (byte) ((Enum<?>) object).ordinal());
                offset++;
            } else {
                throw new IllegalArgumentException("Unknown object type: " + object.getClass());
            }
        }
View Full Code Here

   
    public void append(Buffer buffer) {
        if (this.buffer == null) {
            this.buffer = buffer;
        } else {
            Buffer newBuffer = Buffer.create(this.buffer.length() + buffer.length());
            this.buffer.copy(newBuffer);
            buffer.copy(newBuffer, this.buffer.length());
            this.buffer = newBuffer;
        }
    }
View Full Code Here

TOP

Related Classes of org.gwtnode.core.node.buffer.Buffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.