/** * @deprecated don't do this * @throws I2CPMessageException always */ @Deprecated protected void doReadMessage(InputStream in, int size) throws I2CPMessageException { throw new I2CPMessageException("Don't do this"); }
/** * @deprecated don't do this * @throws I2CPMessageException always */ @Deprecated protected byte[] doWriteMessage() throws I2CPMessageException { throw new I2CPMessageException("Don't do this"); }
/** * Add this message to the writer's queue * * Nonblocking, throws exception if queue is full */ public void addMessage(I2CPMessage msg) throws I2CPMessageException { boolean success = _messagesToWrite.offer(msg); if (!success) throw new I2CPMessageException("I2CP write to queue failed"); //if (_log.shouldLog(Log.DEBUG)) // _log.debug("["+_id+"] addMessage completed for " + msg.getClass().getName()); }
@Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { if (_sessionConfig == null) throw new I2CPMessageException("Unable to write out the message as there is not enough data"); ByteArrayOutputStream os = new ByteArrayOutputStream(64); try { _sessionConfig.writeBytes(os); } catch (DataFormatException dfe) { throw new I2CPMessageException("Error writing out the session config", dfe); } return os.toByteArray(); }
@Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { if (_sessionId == null) throw new I2CPMessageException("Unable to write out the message as there is not enough data"); ByteArrayOutputStream os = new ByteArrayOutputStream(64); try { _sessionId.writeBytes(os); } catch (DataFormatException dfe) { throw new I2CPMessageException("Error writing out the message data", dfe); } return os.toByteArray(); }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { for (int i = 0; i < LIMITS; i++) { data[i] = (int) DataHelper.readLong(in, 4); } } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _reason = DataHelper.readString(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
@Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(64); try { DataHelper.writeString(os, _reason); } catch (DataFormatException dfe) { throw new I2CPMessageException("Error writing out the message data", dfe); } return os.toByteArray(); }
@Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(64); try { for (int i = 0; i < LIMITS; i++) { DataHelper.writeLong(os, 4, data[i]); } } catch (DataFormatException dfe) { throw new I2CPMessageException("Error writing out the message data", dfe); } return os.toByteArray(); }
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { //Hash h = new Hash(); try { //h.readBytes(in); _hash = Hash.create(in); //} catch (DataFormatException dfe) { } catch (IllegalArgumentException dfe) { throw new I2CPMessageException("Unable to load the hash", dfe); } //_hash = h; }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { if (size > 0) { try { _version = DataHelper.readString(in); if (size > 1 + _version.length()) // assume ascii _options = DataHelper.readProperties(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Bad version string", dfe); } } }
@Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { if ((_sessionId < 0) || (_messageId < 0)) throw new I2CPMessageException("Unable to write out the message as there is not enough data"); byte rv[] = new byte[2+4]; DataHelper.toLong(rv, 0, 2, _sessionId); DataHelper.toLong(rv, 2, 4, _messageId); return rv; }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _date = DataHelper.readDate(in); if (size > DataHelper.DATE_LENGTH) _version = DataHelper.readString(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = (int) DataHelper.readLong(in, 2); _messageId = DataHelper.readLong(in, 4); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); _sessionId.readBytes(in); _status = (int) DataHelper.readLong(in, 1); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { SessionConfig config = new SessionConfig(); try { config.readBytes(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the session configuration", dfe); } setSessionConfig(config); }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = (int) DataHelper.readLong(in, 2); _messageId = DataHelper.readLong(in, 4); _payload = new Payload(); _payload.readBytes(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); _sessionId.readBytes(in); _sessionConfig = new SessionConfig(); _sessionConfig.readBytes(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); _sessionId.readBytes(in); _reqID = DataHelper.readLong(in, 4); _code = (int) DataHelper.readLong(in, 1); if (_code == RESULT_SUCCESS) _dest = Destination.create(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("bad data", dfe); } }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = (int) DataHelper.readLong(in, 2); _messageId = DataHelper.readLong(in, 4); _status = (int) DataHelper.readLong(in, 1); _size = DataHelper.readLong(in, 4); _nonce = DataHelper.readLong(in, 4); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }