public void run() { String fileName; boolean verify_checksum; ResponseCallbackOpen cb = new ResponseCallbackOpen(mComm, mEvent); try { if (mEvent.payload.remaining() < 2) throw new ProtocolException("Truncated message"); int version = (int) mEvent.payload.get(); if (version != VERSION) throw new ProtocolException( "Open parameters version mismatch, expected " + VERSION + ", got " + version); int encoding_length = Serialization.DecodeVInt32(mEvent.payload); int start_position = mEvent.payload.position(); int flags = mEvent.payload.getInt(); int bufferSize = mEvent.payload.getInt(); if ((fileName = Serialization.DecodeVStr(mEvent.payload)) == null) throw new ProtocolException("Filename not properly encoded in request packet"); if ((mEvent.payload.position() - start_position) < encoding_length) mEvent.payload.position(start_position + encoding_length); mBroker.Open(cb, fileName, flags, bufferSize); } catch (Exception e) { int error = cb.error(Error.PROTOCOL_ERROR, e.getMessage()); log.severe("Protocol error (OPEN) - " + e.getMessage()); if (error != Error.OK) log.severe("Problem sending (OPEN) error back to client - " + Error.GetText(error)); } }
public void run() { int fd; ResponseCallback cb = new ResponseCallback(mComm, mEvent); try { if (mEvent.payload.remaining() < 2) throw new ProtocolException("Truncated message"); int version = (int) mEvent.payload.get(); if (version != VERSION) throw new ProtocolException( "Close parameters version mismatch, expected " + VERSION + ", got " + version); int encoding_length = Serialization.DecodeVInt32(mEvent.payload); int start_position = mEvent.payload.position(); fd = mEvent.payload.getInt(); if ((mEvent.payload.position() - start_position) < encoding_length) mEvent.payload.position(start_position + encoding_length); mBroker.Close(cb, fd); } catch (Exception e) { int error = cb.error(Error.PROTOCOL_ERROR, e.getMessage()); log.severe("Protocol error (CLOSE) - " + e.getMessage()); if (error != Error.OK) log.severe("Problem sending (CLOSE) error back to client - " + Error.GetText(error)); } }
public void encode(ByteBuffer buf) { Serialization.EncodeString(buf, mClientName); mResult.encode(buf); }
public void decode(ByteBuffer buf) { mClientName = Serialization.DecodeString(buf); mResult = new Result(); mResult.decode(buf); }
public int encodedLength() { return Serialization.EncodedLengthString(mClientName) + mResult.encodedLength(); }