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 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 org.teavm.jso.core.JSPromise<org.teavm.jso.JSObject> failed(SocketObject object, WebSocket socket, String message, DurableState state, Env env) Runs a failure.static org.teavm.jso.core.JSPromise<Response> fetch(DurableObject object, Request request, DurableState state, Env env) Runs a request.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.
-
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 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
-