mirror of
https://github.com/meshcore-dev/meshcore.js.git
synced 2026-04-20 22:13:49 +00:00
ui to test channels
This commit is contained in:
parent
209992d307
commit
78e990aeac
2 changed files with 26 additions and 0 deletions
20
index.html
20
index.html
|
|
@ -113,6 +113,12 @@
|
|||
<button @click="getChannels" class="border border-gray-500 px-2 bg-gray-100 hover:bg-gray-200 rounded">
|
||||
GetChannels
|
||||
</button>
|
||||
<button @click="setChannel" class="border border-gray-500 px-2 bg-gray-100 hover:bg-gray-200 rounded">
|
||||
SetChannel
|
||||
</button>
|
||||
<button @click="deleteChannel" class="border border-gray-500 px-2 bg-gray-100 hover:bg-gray-200 rounded">
|
||||
DeleteChannel
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -537,6 +543,20 @@
|
|||
alert("Failed to get channels!");
|
||||
}
|
||||
},
|
||||
async setChannel() {
|
||||
try {
|
||||
await this.connection.setChannel(1, "Test Channel", BufferUtils.base64ToBytes("RQKLcABJ8tLX+7yerzS9Rw=="));
|
||||
} catch(e) {
|
||||
alert("Failed to set channel!");
|
||||
}
|
||||
},
|
||||
async deleteChannel() {
|
||||
try {
|
||||
await this.connection.deleteChannel(1);
|
||||
} catch(e) {
|
||||
alert("Failed to delete channel!");
|
||||
}
|
||||
},
|
||||
async login(contact) {
|
||||
|
||||
// ask user for password
|
||||
|
|
|
|||
|
|
@ -6,6 +6,12 @@ class BufferUtils {
|
|||
}).join('');
|
||||
}
|
||||
|
||||
static base64ToBytes(base64) {
|
||||
return Uint8Array.from(atob(base64), (c) => {
|
||||
return c.charCodeAt(0);
|
||||
});
|
||||
}
|
||||
|
||||
static areBuffersEqual(byteArray1, byteArray2) {
|
||||
|
||||
// ensure length is the same
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue