/** * @param json Json value to use * @return An event with a string representation of {@code json} as content */ public static Event event(JsonNode json) { return new Event(Json.stringify(json), null, null); }
/** * Send an event. On the client, a 'message' event listener can be setup to listen to this event. * * @param event Event content */ public void send(Event event) { out.write(event.formatted()); }
/** * @param data Event content * @return An event with {@code data} as content */ public static Event event(String data) { return new Event(data, null, null); }
/** * @param id Event id * @return A copy of this event, with id {@code id}. */ public Event withId(String id) { return new Event(this.data, id, this.name); }
/** * @param data Event content * @return An event with {@code data} as content */ public static Event event(String data) { return new Event(data, null, null); }
/** * @param id Event id * @return A copy of this event, with id {@code id}. */ public Event withId(String id) { return new Event(this.data, id, this.name); }
/** * @param json Json value to use * @return An event with a string representation of {@code json} as content */ public static Event event(JsonNode json) { return new Event(Json.stringify(json), null, null); }
/** * @param id Event id * @return A copy of this event, with id {@code id}. */ public Event withId(String id) { return new Event(this.data, id, this.name); }
/** * @param name Event name * @return A copy of this event, with name {@code name} */ public Event withName(String name) { return new Event(this.data, this.id, name); }
/** * @param id Event id * @return A copy of this event, with id {@code id}. */ public Event withId(String id) { return new Event(this.data, id, this.name); }
/** * @return a flow of EventSource.Event to ByteString. */ public static Flow<EventSource.Event, ByteString, ?> flow() { Flow<Event, Event, NotUsed> flow = Flow.of(Event.class); return flow.map((EventSource.Event event) -> ByteString.fromString(event.formatted())); }
/** * @param name Event name * @return A copy of this event, with name {@code name} */ public Event withName(String name) { return new Event(this.data, this.id, name); }
/** * @param data Event content * @return An event with {@code data} as content */ public static Event event(String data) { return new Event(data, null, null); }
/** * @param data Event content * @return An event with {@code data} as content */ public static Event event(String data) { return new Event(data, null, null); }
/** * @return a flow of EventSource.Event to ByteString. */ public static Flow<EventSource.Event, ByteString, ?> flow() { Flow<Event, Event, NotUsed> flow = Flow.of(Event.class); return flow.map((EventSource.Event event) -> ByteString.fromString(event.formatted())); }
/** * @param name Event name * @return A copy of this event, with name {@code name} */ public Event withName(String name) { return new Event(this.data, this.id, name); }
/** * @param json Json value to use * @return An event with a string representation of {@code json} as content */ public static Event event(JsonNode json) { return new Event(Json.stringify(json), null, null); }
/** * @return a flow of EventSource.Event to ByteString. */ public static Flow<EventSource.Event, ByteString, ?> flow() { Flow<Event, Event, NotUsed> flow = Flow.of(Event.class); return flow.map((EventSource.Event event) -> ByteString.fromString(event.formatted())); }
/** * @param name Event name * @return A copy of this event, with name {@code name} */ public Event withName(String name) { return new Event(this.data, this.id, name); }
/** * @param json Json value to use * @return An event with a string representation of {@code json} as content */ public static Event event(JsonNode json) { return new Event(Json.stringify(json), null, null); }