Message sending

This commit is contained in:
2026-08-20 10:53:52 +02:00
parent fc1c550a2e
commit 8bdae4ceb8
3 changed files with 54 additions and 1 deletions
+25
View File
@@ -44,6 +44,31 @@ export default class Enclave<P = Page> {
return this.accounts?.accounts[this.accounts.activeAccount] || null;
}
public sendMessage(content: string, channelId: string) {
const clientSecretKey = this.getClientSecretKey();
if (!clientSecretKey) {
console.error("Acccount not found");
return;
}
const timestamp = Date.now();
const signature = new TextEncoder().encode(
`${timestamp}@${this.server?.hostname}@${content}`,
);
this.server?.websocket?.send({
method: "SendMessage",
channel_id: channelId,
data: {
content,
timestamp,
signature: base58.encode(ed.sign(signature, clientSecretKey)),
},
});
}
public async connectToServer(hostname: string, isSecure: boolean) {
if (this.server) {
this.server.disconnect();