Example usage for io.netty.buffer ByteBuf writeLong

List of usage examples for io.netty.buffer ByteBuf writeLong

Introduction

In this page you can find the example usage for io.netty.buffer ByteBuf writeLong.

Prototype

public abstract ByteBuf writeLong(long value);

Source Link

Document

Sets the specified 64-bit long integer at the current writerIndex and increases the writerIndex by 8 in this buffer.

Usage

From source file:com.teambrmodding.neotech.network.OpenContainerGuiPacket.java

License:Creative Commons License

@Override
public void toBytes(ByteBuf buf) {
    buf.writeLong(blockPos.toLong());
    buf.writeInt(id);
}

From source file:com.tesora.dve.db.mysql.common.MysqlAPIUtils.java

License:Open Source License

public static void putLengthCodedLong(ByteBuf cb, long length) {
    if (length <= LEN_CODED_8_BITS) {
        cb.writeByte((int) length); // length is 1 byte
    } else if (length <= UNSIGNED_SHORT_MAX) {
        cb.writeByte(LEN_CODED_16_BITS); // length is 2 bytes
        cb.writeShort((int) length);
    } else if (length <= UNSIGNED_MEDIUM_MAX) {
        cb.writeByte(LEN_CODED_24_BITS); // length is 3 bytes
        cb.writeMedium((int) length);
    } else {//  ww w .  j a va  2s  . c o m
        cb.writeByte(LEN_CODED_64_BITS); // length is 8 bytes
        cb.writeLong(length);
    }
}

From source file:com.tesora.dve.mysqlapi.repl.messages.MyIntvarLogEvent.java

License:Open Source License

@Override
public void marshallMessage(ByteBuf cb) {
    cb.writeByte(variableType);
    cb.writeLong(variableValue.longValue());
}

From source file:com.tesora.dve.mysqlapi.repl.messages.MyRandLogEvent.java

License:Open Source License

@Override
public void marshallMessage(ByteBuf cb) {
    cb.writeLong(seed1.longValue());
    cb.writeLong(seed2.longValue());
}

From source file:com.tesora.dve.mysqlapi.repl.messages.MyRotateLogEvent.java

License:Open Source License

@Override
public void marshallMessage(ByteBuf cb) {
    cb.writeLong(position);
    cb.writeBytes(newLogFileName.getBytes(CharsetUtil.UTF_8));
}

From source file:com.tesora.dve.mysqlapi.repl.messages.MyStatusVariables.java

License:Open Source License

public void writeStatusVariables(ByteBuf cb) {
    for (BaseQueryEvent qe : getSuppliedEventCodes()) {
        MyQueryEventCode code = qe.getCode();
        switch (code) {
        case Q_FLAGS2_CODE:
            cb.writeByte(code.getByteValue());
            cb.writeInt(((QueryFlags2Event) qe).getFlags());
            break;

        case Q_SQL_MODE_CODE:
            cb.writeByte(code.getByteValue());
            cb.writeLong(((QuerySQLModeEvent) qe).getSqlMode());
            break;

        case Q_CATALOG_CODE:
            cb.writeByte(code.getByteValue());
            cb.writeByte(((QueryCatalogEvent) qe).getCatalog().length());
            cb.writeBytes(((QueryCatalogEvent) qe).getCatalog().getBytes());
            cb.writeByte(0); //for trailing 0
            break;

        case Q_AUTO_INCREMENT:
            cb.writeByte(code.getByteValue());
            cb.writeShort(((QueryAutoIncrementEvent) qe).getAutoIncrementIncrement());
            cb.writeShort(((QueryAutoIncrementEvent) qe).getAutoIncrementOffset());
            break;

        case Q_CHARSET_CODE:
            cb.writeByte(code.getByteValue());
            cb.writeShort(((QueryCharSetCodeEvent) qe).getCharSetClient());
            cb.writeShort(((QueryCharSetCodeEvent) qe).getCollationConnection());
            cb.writeShort(((QueryCharSetCodeEvent) qe).getCollationServer());
            break;

        case Q_TIME_ZONE_CODE:
            cb.writeByte(code.getByteValue());
            cb.writeByte(((QueryTimeZoneCodeEvent) qe).getTimeZone().length());
            cb.writeBytes(((QueryTimeZoneCodeEvent) qe).getTimeZone().getBytes());
            break;

        case Q_CATALOG_NZ_CODE:
            cb.writeByte(code.getByteValue());
            cb.writeByte(((QueryCatalogNZEvent) qe).getCatalog().length());
            cb.writeBytes(((QueryCatalogNZEvent) qe).getCatalog().getBytes());
            break;

        case Q_LC_TIME_NAMES_CODE:
            cb.writeByte(code.getByteValue());
            cb.writeShort(((QueryTimeNamesEvent) qe).getMonthDayNames());
            break;

        case Q_CHARSET_DATABASE_CODE:
            cb.writeByte(code.getByteValue());
            cb.writeShort(((QueryCollationDatabaseEvent) qe).getCollationDatabase());
            break;

        case Q_TABLE_MAP_FOR_UPDATE_CODE:
            cb.writeByte(code.getByteValue());
            cb.writeLong(((QueryTableMapEvent) qe).getTableMapForUpdate());
            break;

        case Q_MASTER_DATA_WRITTEN_CODE:
            cb.writeByte(code.getByteValue());
            cb.writeInt(((QueryMasterDataWrittenEvent) qe).getOriginalLength());
            break;

        case Q_INVOKER:
            cb.writeByte(code.getByteValue());
            cb.writeByte(((QueryInvokerEvent) qe).getUser().length());
            cb.writeBytes(((QueryInvokerEvent) qe).getUser().getBytes());
            cb.writeByte(((QueryInvokerEvent) qe).getHost().length());
            cb.writeBytes(((QueryInvokerEvent) qe).getHost().getBytes());
            break;

        case Q_UPDATED_DB_NAMES:
            cb.writeByte(code.getByteValue());
            List<String> dbs = ((QueryUpdatedDBNamesEvent) qe).getDbNames();
            cb.writeByte(dbs == null ? 0 : dbs.size());
            if (dbs.size() > 0) {
                for (String db : dbs) {
                    cb.writeByte(db.length());
                    cb.writeBytes(db.getBytes(CharsetUtil.UTF_8));
                    cb.writeByte(0); //for trailing 0
                }/*from w ww . ja v a 2 s .  c om*/
            }
            break;

        case Q_MICROSECONDS:
            cb.writeByte(code.getByteValue());
            cb.writeMedium(((QueryMicrosecondsEvent) qe).getMicroseconds());
            break;

        case Q_HRNOW:
            cb.writeMedium(((QueryHRNowEvent) qe).threeBytes);
            break;

        default:
            break;
        }
    }
}

From source file:com.tesora.dve.mysqlapi.repl.messages.MyXIdLogEvent.java

License:Open Source License

@Override
public void marshallMessage(ByteBuf cb) {
    cb.writeLong(xid);
}

From source file:com.turn.ttorrent.common.protocol.udp.UDPAnnounceRequestMessage.java

License:Apache License

@Override
public void toWire(ByteBuf out) {
    _toWire(out);/*w w w . j  ava 2  s  .c  o m*/
    out.writeBytes(infoHash);
    out.writeBytes(getPeerId());
    out.writeLong(downloaded);
    out.writeLong(uploaded);
    out.writeLong(left);
    out.writeInt(event.getId());
    out.writeBytes(getIp4Address(peerAddress));
    out.writeInt(key);
    out.writeInt(numWant);
    out.writeShort(peerAddress.getPort());
}

From source file:com.turn.ttorrent.common.protocol.udp.UDPConnectResponseMessage.java

License:Apache License

@Override
public void toWire(ByteBuf out) {
    _toWire(out);
    out.writeLong(connectionId);
}

From source file:com.twitter.http2.HttpFrameDecoderTest.java

License:Apache License

@Test
public void testHttpPingFrame() throws Exception {
    int length = 8;
    byte flags = 0;
    int streamId = 0; // connection identifier
    long data = RANDOM.nextLong();

    ByteBuf frame = pingFrame(length, flags, streamId);
    frame.writeLong(data);
    decoder.decode(frame);/*w w w .j ava  2s .  c  o m*/

    verify(delegate).readPingFrame(data, false);
    verifyNoMoreInteractions(delegate);
}