Interface Writer

  • All Known Implementing Classes:
    PacketWriter

    public interface Writer
    • Method Detail

      • pos

        int pos()
      • writeByte

        void writeByte​(int value)
                throws IOException
        Write byte into buf, flush buf to socket if needed.
        Parameters:
        value - byte to send
        Throws:
        IOException - if socket error occur.
      • writeShort

        void writeShort​(short value)
                 throws IOException
        Write short value into buf. flush buf if too small.
        Parameters:
        value - short value
        Throws:
        IOException - if socket error occur
      • writeInt

        void writeInt​(int value)
               throws IOException
        Write int value into buf. flush buf if too small.
        Parameters:
        value - int value
        Throws:
        IOException - if socket error occur
      • writeLong

        void writeLong​(long value)
                throws IOException
        Write long value into buf. flush buf if too small.
        Parameters:
        value - long value
        Throws:
        IOException - if socket error occur
      • writeBytesAtPos

        void writeBytesAtPos​(byte[] arr,
                             int pos)
      • writeBytes

        void writeBytes​(byte[] arr,
                        int off,
                        int len)
                 throws IOException
        Write byte array to buf. If buf is full, flush socket.
        Parameters:
        arr - byte array
        off - offset
        len - byte length to write
        Throws:
        IOException - if socket error occur
      • writeLength

        void writeLength​(long length)
                  throws IOException
        Write field length into buf, flush socket if needed.
        Parameters:
        length - field length
        Throws:
        IOException - if socket error occur.
      • writeStringEscaped

        void writeStringEscaped​(String str,
                                boolean noBackslashEscapes)
                         throws IOException
        Write string to socket.
        Parameters:
        str - string
        noBackslashEscapes - escape method
        Throws:
        IOException - if socket error occur
      • writeBytesEscaped

        void writeBytesEscaped​(byte[] bytes,
                               int len,
                               boolean noBackslashEscapes)
                        throws IOException
        Write escape bytes to socket.
        Parameters:
        bytes - bytes
        len - len to write
        noBackslashEscapes - escape method
        Throws:
        IOException - if socket error occur
      • writeEmptyPacket

        void writeEmptyPacket()
                       throws IOException
        Send empty packet.
        Throws:
        IOException - if socket error occur.
      • throwMaxAllowedLength

        boolean throwMaxAllowedLength​(int length)
      • getCmdLength

        long getCmdLength()
      • setMaxAllowedPacket

        void setMaxAllowedPacket​(int maxAllowedPacket)
      • permitTrace

        void permitTrace​(boolean permitTrace)
      • setServerThreadId

        void setServerThreadId​(Long serverThreadId,
                               HostAddress hostAddress)
        Set server thread id.
        Parameters:
        serverThreadId - current server thread id.
        hostAddress - host information
      • mark

        void mark()
      • isMarked

        boolean isMarked()
      • hasFlushed

        boolean hasFlushed()
      • flushBufferStopAtMark

        void flushBufferStopAtMark()
                            throws IOException
        Flush to last mark.
        Throws:
        IOException - if flush fail.
      • bufIsDataAfterMark

        boolean bufIsDataAfterMark()
      • resetMark

        byte[] resetMark()
        Reset mark flag and send bytes after mark flag.
        Returns:
        bytes after mark flag
      • initPacket

        void initPacket()