Package dev.gmitch215.bytebox.durable
Class DurableHandlers
java.lang.Object
dev.gmitch215.bytebox.durable.DurableHandlers
What the generated Durable Object exports call.
The generated JavaScript class the runtime instantiates forwards each method here with the instance's identifier, and each one starts the handler on a fiber and hands JavaScript a promise. A handler cannot be called directly from a promise executor, because an executor cannot suspend and every binding call does.
Not part of the surface a project writes against. It is public because generated code in another package calls it.
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> alarm(AlarmObject object, DurableState state, Env env) Runs an alarm.static <T extends AlarmObject>
org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> alarm(String identifier, Supplier<T> factory, DurableState state, Env env) Runs an alarm on the instance for an identifier, building the instance on the same fiber.static org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> closed(SocketObject object, WebSocket socket, int code, String reason, boolean clean, DurableState state, Env env) Runs a close.static <T extends SocketObject>
org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> closed(String identifier, Supplier<T> factory, WebSocket socket, int code, String reason, boolean clean, DurableState state, Env env) Runs a close on the instance for an identifier, building the instance on the same fiber.static org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> failed(SocketObject object, WebSocket socket, String message, DurableState state, Env env) Runs a failure.static <T extends SocketObject>
org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> failed(String identifier, Supplier<T> factory, WebSocket socket, String message, DurableState state, Env env) Runs a failure on the instance for an identifier, building the instance on the same fiber.static org.teavm.jso.core.JSPromise<Response> fetch(DurableObject object, Request request, DurableState state, Env env) Runs a request.static <T extends DurableObject>
org.teavm.jso.core.JSPromise<Response> Runs a request on the instance for an identifier, building the instance on the same fiber.static <T> TThe instance for an identifier, built on first use.static org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> message(SocketObject object, WebSocket socket, String text, DurableState state, Env env) Runs a text message.static org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> message(SocketObject object, WebSocket socket, org.teavm.jso.typedarrays.ArrayBuffer bytes, DurableState state, Env env) Runs a binary message.static <T extends SocketObject>
org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> message(String identifier, Supplier<T> factory, WebSocket socket, String text, DurableState state, Env env) Runs a text message on the instance for an identifier, building the instance on the same fiber.static <T extends SocketObject>
org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> message(String identifier, Supplier<T> factory, WebSocket socket, org.teavm.jso.typedarrays.ArrayBuffer bytes, DurableState state, Env env) Runs a binary message on the instance for an identifier, building the instance on the same fiber.
-
Method Details
-
instance
The instance for an identifier, built on first use.- Type Parameters:
T- the object's type- Parameters:
identifier- the Durable Object's identifierfactory- how to build one- Returns:
- the instance
-
fetch
public static <T extends DurableObject> org.teavm.jso.core.JSPromise<Response> fetch(String identifier, Supplier<T> factory, Request request, DurableState state, Env env) Runs a request on the instance for an identifier, building the instance on the same fiber.The form the generated entry point calls, so a constructor that locks, joins or waits works. A constructor that throws rejects the promise.
- Type Parameters:
T- the object's type- Parameters:
identifier- the Durable Object's identifierfactory- how to build onerequest- the requeststate- the instance's contextenv- the bindings- Returns:
- the response, once the handler has produced one
- Since:
- 1.0.3
-
alarm
public static <T extends AlarmObject> org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> alarm(String identifier, Supplier<T> factory, DurableState state, Env env) Runs an alarm on the instance for an identifier, building the instance on the same fiber.- Type Parameters:
T- the object's type- Parameters:
identifier- the Durable Object's identifierfactory- how to build onestate- the instance's contextenv- the bindings- Returns:
- a promise that settles when the handler returns
- Since:
- 1.0.3
-
message
public static <T extends SocketObject> org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> message(String identifier, Supplier<T> factory, WebSocket socket, String text, DurableState state, Env env) Runs a text message on the instance for an identifier, building the instance on the same fiber.- Type Parameters:
T- the object's type- Parameters:
identifier- the Durable Object's identifierfactory- how to build onesocket- which connection sent ittext- the messagestate- the instance's contextenv- the bindings- Returns:
- a promise that settles when the handler returns
- Since:
- 1.0.3
-
message
public static <T extends SocketObject> org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> message(String identifier, Supplier<T> factory, WebSocket socket, org.teavm.jso.typedarrays.ArrayBuffer bytes, DurableState state, Env env) Runs a binary message on the instance for an identifier, building the instance on the same fiber.- Type Parameters:
T- the object's type- Parameters:
identifier- the Durable Object's identifierfactory- how to build onesocket- which connection sent itbytes- the messagestate- the instance's contextenv- the bindings- Returns:
- a promise that settles when the handler returns
- Since:
- 1.0.3
-
closed
public static <T extends SocketObject> org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> closed(String identifier, Supplier<T> factory, WebSocket socket, int code, String reason, boolean clean, DurableState state, Env env) Runs a close on the instance for an identifier, building the instance on the same fiber.- Type Parameters:
T- the object's type- Parameters:
identifier- the Durable Object's identifierfactory- how to build onesocket- which connection closedcode- the close codereason- the close reasonclean- whether the peer closed properlystate- the instance's contextenv- the bindings- Returns:
- a promise that settles when the handler returns
- Since:
- 1.0.3
-
failed
public static <T extends SocketObject> org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> failed(String identifier, Supplier<T> factory, WebSocket socket, String message, DurableState state, Env env) Runs a failure on the instance for an identifier, building the instance on the same fiber.- Type Parameters:
T- the object's type- Parameters:
identifier- the Durable Object's identifierfactory- how to build onesocket- which connection failedmessage- what went wrongstate- the instance's contextenv- the bindings- Returns:
- a promise that settles when the handler returns
- Since:
- 1.0.3
-
fetch
public static org.teavm.jso.core.JSPromise<Response> fetch(DurableObject object, Request request, DurableState state, Env env) Runs a request.- Parameters:
object- the instancerequest- the requeststate- the instance's contextenv- the bindings- Returns:
- the response, once the handler has produced one
-
alarm
public static org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> alarm(AlarmObject object, DurableState state, Env env) Runs an alarm.- Parameters:
object- the instancestate- the instance's contextenv- the bindings- Returns:
- a promise that settles when the handler returns
-
message
public static org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> message(SocketObject object, WebSocket socket, String text, DurableState state, Env env) Runs a text message.- Parameters:
object- the instancesocket- which connection sent ittext- the messagestate- the instance's contextenv- the bindings- Returns:
- a promise that settles when the handler returns
-
message
public static org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> message(SocketObject object, WebSocket socket, org.teavm.jso.typedarrays.ArrayBuffer bytes, DurableState state, Env env) Runs a binary message.- Parameters:
object- the instancesocket- which connection sent itbytes- the messagestate- the instance's contextenv- the bindings- Returns:
- a promise that settles when the handler returns
-
closed
public static org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> closed(SocketObject object, WebSocket socket, int code, String reason, boolean clean, DurableState state, Env env) Runs a close.- Parameters:
object- the instancesocket- which connection closedcode- the close codereason- the close reasonclean- whether the peer closed properlystate- the instance's contextenv- the bindings- Returns:
- a promise that settles when the handler returns
-
failed
public static org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> failed(SocketObject object, WebSocket socket, String message, DurableState state, Env env) Runs a failure.- Parameters:
object- the instancesocket- which connection failedmessage- what went wrongstate- the instance's contextenv- the bindings- Returns:
- a promise that settles when the handler returns
-