-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nodejs nym-wasm-client working, needs polishing
Signed-off-by: Sebastian Martinez <[email protected]>
- Loading branch information
1 parent
d9041cf
commit c0fd74b
Showing
10 changed files
with
175 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,28 @@ | ||
import { createNymMixnetClient } from '../dist/cjs-full-fat/index.cjs'; | ||
|
||
debugger; | ||
import { createNymMixnetClient } from '../dist/cjs/index.js'; | ||
|
||
const nym = await createNymMixnetClient(); | ||
|
||
const nymApiUrl = 'https://validator.nymtech.net/api'; | ||
// show message payload content when received | ||
nym.events.subscribeToTextMessageReceivedEvent((e) => { | ||
console.log('Got a message: ', e.args.payload); | ||
nym.events.subscribeToLoaded((e) => { | ||
console.log('Loaded'); | ||
}); | ||
|
||
nym.events.subscribeToTextMessageReceivedEvent(async (e) => { | ||
console.log(e.args.payload); | ||
if (e.args.payload === 'Hello') await nym.client.stop(); | ||
}); | ||
|
||
const nymApiUrl = 'https://validator.nymtech.net/api/'; | ||
|
||
// start the client and connect to a gateway | ||
await nym.client.start({ | ||
clientId: 'My awesome client', | ||
nymApiUrl, | ||
clientId: 'my-client', | ||
}); | ||
|
||
// send a message to yourself | ||
const payload = 'Hello mixnet'; | ||
const recipient = await nym.client.selfAddress(); | ||
console.log(recipient) | ||
debugger; | ||
await nym.client.send({ payload, recipient }); | ||
nym.events.subscribeToConnected(async (e) => { | ||
console.log('Connected'); | ||
// send a message to yourself | ||
const message = 'Hello'; | ||
const recipient = await nym.client.selfAddress(); | ||
await nym.client.send({ payload: { message, mimeType: 'text/plain' }, recipient }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.