@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); } }
public void readBytes(InputStream in) throws DataFormatException, IOException { //_gateway = new Hash(); //_gateway.readBytes(in); _gateway = Hash.create(in); _tunnelId = new TunnelId(); _tunnelId.readBytes(in); _end = DataHelper.readDate(in); }
@Test public void testDate() throws Exception{ byte[] temp = null; Date orig = new Date(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataHelper.writeDate(baos, orig); temp = baos.toByteArray(); Date d = null; ByteArrayInputStream bais = new ByteArrayInputStream(temp); d = DataHelper.readDate(bais); assertEquals(orig, d); } }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); _sessionId.readBytes(in); int numTunnels = (int) DataHelper.readLong(in, 1); _endpoints.clear(); for (int i = 0; i < numTunnels; i++) { //Hash router = new Hash(); //router.readBytes(in); Hash router = Hash.create(in); TunnelId tunnel = new TunnelId(); tunnel.readBytes(in); _endpoints.add(new TunnelEndpoint(router, tunnel)); } _end = DataHelper.readDate(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
public void readBytes(InputStream rawConfig) throws DataFormatException, IOException { _destination = Destination.create(rawConfig); _options = DataHelper.readProperties(rawConfig); _creationDate = DataHelper.readDate(rawConfig); _signature = new Signature(_destination.getSigningPublicKey().getType()); _signature.readBytes(rawConfig); }