protected void sendDatagram (UpstreamMessage msg)
        throws IOException
    {
        // reset the stream and write our connection id and hash placeholder
        _bout.reset();
        _uout.writeInt(_client.getConnectionId());
        _uout.writeLong(0L);

        // write the datagram through the sequencer
        _sequencer.writeDatagram(msg);

        // flip the buffer and make sure it's not too long
        ByteBuffer buf = _bout.flip();
        int size = buf.remaining();
        if (size > Client.MAX_DATAGRAM_SIZE) {
            log.warning("Dropping oversized datagram", "size", size, "msg", msg);
            return;
        }

        // compute the hash
        buf.position(12);
        _digest.update(buf);
        byte[] hash = _digest.digest(_secret);

        // insert the first 64 bits of the hash
        buf.position(4);
        buf.put(hash, 0, 8).rewind();

        // send the datagram
        writeDatagram(buf);

        // notify the tracker
        _client.getMessageTracker().messageSent(true, size, msg);
    }
protected void sendDatagram ( UpstreamMessage msg ) throws IOException { _bout . reset ( ) ; _uout . writeInt ( _client . getConnectionId ( ) ) ; _uout . writeLong ( 0L ) ; _sequencer . writeDatagram ( msg ) ; ByteBuffer buf = _bout . flip ( ) ; int size = buf . remaining ( ) ; if ( size > Client . MAX_DATAGRAM_SIZE ) { log . warning ( "Dropping oversized datagram" , "size" , size , "msg" , msg ) ; return ; } buf . position ( 12 ) ; _digest . update ( buf ) ; byte [ ] hash = _digest . digest ( _secret ) ; buf . position ( 4 ) ; buf . put ( hash , 0 , 8 ) . rewind ( ) ; writeDatagram ( buf ) ; _client . getMessageTracker ( ) . messageSent ( true , size , msg ) ; }
Sends a datagram over the datagram socket.