@Override public Binder serialize(Object object, BiSerializer serializer) { ItemInfo ii = (ItemInfo)object; return Binder.fromKeysValues( "item_result", ii.itemResult, "item_id", ii.itemId, "errors", ii.errors ); }
@Override public Binder serialize(BiSerializer s) { return Binder.fromKeysValues( "anonymousId", anonymousId ); }
/** * Get collected report as a Binder object. * * @return */ public Binder report() { return Binder.fromKeysValues( "messages", messages, "errors", errors ); }
public Binder toBinder() { return Binder.fromKeysValues( "id", id, "instant", instant.getEpochSecond(), "message", message ); }
@Override public Binder onUpdated(MutableEnvironment me) { updateSubscriptions(me); return Binder.fromKeysValues("status", "ok"); }
/** * Execute command over the authenticated and encrypted connection. See {@link #command(String, Binder)} for more. * @param name command name * @param keysValues keys (strings) and values of the command arguments. Values can be anything {@link Boss} protocol * and registered adapters support * @return command result * @throws IOException if the command can't be executed (also if remote returns an error) */ public Binder command(String name, Object... keysValues) throws IOException { return command(name, Binder.fromKeysValues(keysValues)); }
@Override public Binder serialize(Object object, BiSerializer serializer) { ErrorRecord er = (ErrorRecord) object; return Binder.fromKeysValues( "error", er.error.name(), "object", er.objectName, "message", er.message ); }
@Override public Binder onUpdated(MutableEnvironment me) { updateSubscriptions(me); return Binder.fromKeysValues("status", "ok"); }
private Binder onPing(Binder params) { Binder result = Binder.fromKeysValues("ping", "pong"); result.putAll(params); return result; }
public Binder toBinder() { return Binder.fromKeysValues( "state", name() ); }
Binder connect() { if (serverNonce == null) serverNonce = Do.randomBytes(48); return Binder.fromKeysValues( "server_nonce", serverNonce, "session_id", ""+sessionId ); }
@Override public Binder serialize(Object object, BiSerializer serializer) { return Binder.fromKeysValues("seconds", ((ZonedDateTime) object).toEpochSecond()); }
@Override public Binder serialize(Object object, BiSerializer serializer) { return Binder.fromKeysValues("packed", ((PrivateKey) object).pack()); }
@Override public Binder serialize(TestItem item, BiSerializer serializer) { return Binder.fromKeysValues("ok", item.isGood); }
static public byte[] of(byte[] targetSignature, byte[] sign, byte[] sign2) { Binder result = Binder.fromKeysValues( "exts", targetSignature, "sign", sign, "sign2", sign2 ); return Boss.pack(result); }
@Override public @Nullable Binder onCreated(MutableEnvironment me) { updateSubscriptions(me); return Binder.fromKeysValues("status", "ok"); }
public Binder toBinder() { return Binder.fromKeysValues( "state", state.name(), "haveCopy", haveCopy, "createdAt", createdAt, "expiresAt", expiresAt, "errors", DefaultBiMapper.serialize(errors), "isTestnet", isTestnet, "lockedById", lockedById, "extra", extraDataBinder ); }
@Override public @Nullable Binder onCreated(MutableEnvironment me) { ZonedDateTime expiresAt = calcExpiresAt(); storedNames.forEach(sn -> me.createNameRecord(sn,expiresAt)); return Binder.fromKeysValues("status", "ok"); }
public Binder asBinder() { return Binder.fromKeysValues( "connectMessage", getConnectMessage(), // "privateKey", privateKey.pack(), "sessionKey", getSessionKey().pack(), "sessionId", getSessionId() // "nodePublicKey", nodePublicKey.pack() ); }
@Test public void cachingNestedMaps() throws Exception { Binder a = Binder.fromKeysValues("foo", "bar"); Binder b = Binder.fromKeysValues("foo", "bar"); b.put("bar", "buzz"); Binder root = Binder.fromKeysValues("a", b, "b", b, "c", b); Binder res = Boss.unpack(Boss.pack(root)); assertEquals("buzz", res.getBinderOrThrow("c").getStringOrThrow("bar")); }