Appearance
A forwarded message
forwardMessage({ fromThreadId, fromItemId }) builds the message; DirectBroadcast sends it to a conversation. Forwards one message of another conversation.
Example
Forward a message of one conversation into another. The example starts the app from a stored snapshot and sends over the layer, so its answer is the broadcast's: the server's response beside the client_context the request minted.
ts
import { AndroidApp } from '@igpapi/android';
import { DirectBroadcast, forwardMessage, ThreadDirectTargetConfiguration } from '@igpapi/mobile';
import { Effect } from 'effect';
import { readFile } from 'node:fs/promises';
// A snapshot read back from your storage (see "Keep a session").
const snapshot = JSON.parse(await readFile('snapshot.json', 'utf8'));
// Forward a message of one conversation into another: the target conversation's long
// thread id, and the source conversation's thread id and the message's item id.
const forward = DirectBroadcast({
target: new ThreadDirectTargetConfiguration('340282366841710300949128000000000002'),
message: forwardMessage({
fromThreadId: '340282366841710300949128000000000001',
fromItemId: '30000000000000000000000000000000001',
}),
});
// One build of the layer is one app process; the program runs over it.
const sent = await Effect.runPromise(Effect.provide(forward, AndroidApp({ snapshot })));
console.log(sent.client_context);