From 5e0625e197f17eb92abed456a9723edf3bc05f60 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Wed, 2 Jan 2019 17:12:26 -0400 Subject: [PATCH] Updated example with IPC connection --- test-mailserver.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/test-mailserver.js b/test-mailserver.js index 9c7808e..fea7111 100644 --- a/test-mailserver.js +++ b/test-mailserver.js @@ -2,9 +2,12 @@ var StatusJS = require('./dist/index.js'); (async () => { var status = new StatusJS(); - await status.connect("ws://localhost:8546", "0x0011223344556677889900112233445566778899001122334455667788990011"); - // await status.connect("/home/richard/.statusd/geth.ipc"); -console.log(await status.getPublicKey()); + //await status.connect("ws://localhost:8546", "0x0011223344556677889900112233445566778899001122334455667788990011"); + + await status.connect("/home/richard/.statusd/geth.ipc", "0x0011223344556677889900112233445566778899001122334455667788990011"); + + + console.log(await status.getPublicKey()); const channel = "mytest"; await status.joinChat(channel); @@ -24,15 +27,14 @@ console.log(await status.getPublicKey()); status.mailservers.useMailserver(enode, (err, res) => { // Group chats - let from = 1544783388; // unix timestamp - let to = 1544846928; + let from = parseInt((new Date()).getTime() / 1000 - 86400, 10); + let to = parseInt((new Date()).getTime() / 1000, 10); + status.mailservers.requestChannelMessages(channel, {from, to}, (err, res) => { if(err) console.log(err); }); // User messages - from = parseInt((new Date()).getTime() / 1000 - 6000, 10); - to = parseInt((new Date()).getTime() / 1000, 10); status.mailservers.requestUserMessages({from, to}, (err, res) => { if(err) console.log(err); });