implement basic clientside RPC infrastructure
and provide a basic example for testing itpull/1/head
parent
612a00b484
commit
b3cc8da315
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="cp slide">
|
||||
<head>
|
||||
<title>CryptPad</title>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
||||
<script data-bootload="main.js" data-main="/common/boot.js" src="/bower_components/requirejs/require.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="iframe-container">
|
||||
<iframe id="pad-iframe"></iframe><script src="/common/noscriptfix.js"></script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
</head>
|
||||
<body>
|
||||
<h1>PEWPEW
|
@ -0,0 +1,35 @@
|
||||
require.config({ paths: { 'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify' } });
|
||||
define([
|
||||
'/common/cryptpad-common.js',
|
||||
'/common/rpc.js',
|
||||
'/bower_components/jquery/dist/jquery.min.js',
|
||||
], function (Cryptpad, RPC) {
|
||||
var $ = window.jQuery;
|
||||
var APP = window.APP = {
|
||||
Cryptpad: Cryptpad,
|
||||
};
|
||||
|
||||
$(function () {
|
||||
Cryptpad.ready(function (err, env) {
|
||||
var network = Cryptpad.getNetwork();
|
||||
var rpc = RPC.create(network); // TODO signing key
|
||||
|
||||
var payload = {
|
||||
a: Math.floor(Math.random() * 1000),
|
||||
b: 7,
|
||||
};
|
||||
|
||||
// console.log(payload);
|
||||
rpc.send('ECHO', payload, function (e, msg) {
|
||||
if (e) { return void console.error(e); }
|
||||
console.log(msg);
|
||||
});
|
||||
|
||||
// test a non-existent RPC call
|
||||
rpc.send('PEWPEW', ['pew'], function (e, msg) {
|
||||
if (e) { return void console.error(e); }
|
||||
console.log(msg);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue