mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
Create keystore.js
Former-commit-id: 6e57c4fa824b56c208f0910bd462b7145b3a201d [formerly 6750759dea61eb28bc5cca842d5fb3659fd9795b] [formerly 69062d21361147bfc05d329f26e4ba5167a59565 [formerly 169e4b41c9
]]
Former-commit-id: fed116cda64134c4b76f2665f283d08176697b1c [formerly 8654e5a8f910d7f5135572eab42c48511e62f38f]
Former-commit-id: 136a617fe456bdea15c6d4173f6abd9bc4bba819
This commit is contained in:
parent
239341ee87
commit
ad4ed37898
42
keystore/keystore.js
Normal file
42
keystore/keystore.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
function save(key, value) {
|
||||||
|
c = new WebSocket('wss://cowyo.com/ws');
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
try {
|
||||||
|
c.onopen = function (_) {
|
||||||
|
c.send(JSON.stringify({
|
||||||
|
TextData: JSON.stringify(value),
|
||||||
|
Title: `${key}`,
|
||||||
|
UpdateServer: true,
|
||||||
|
UpdateClient: false,
|
||||||
|
}));
|
||||||
|
return resolve(true);
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
return reject(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// save('hello2', 'world');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function get(key) {
|
||||||
|
c = new WebSocket('wss://cowyo.com/ws');
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
try {
|
||||||
|
c.onmessage = function(evt) {
|
||||||
|
return resolve(JSON.parse(JSON.parse(evt.data).TextData));
|
||||||
|
}
|
||||||
|
c.onopen = function (_) {
|
||||||
|
c.send(JSON.stringify({
|
||||||
|
Title: `${key}`,
|
||||||
|
UpdateClient: true,
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
} catch(e) {
|
||||||
|
return reject(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user