mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-20 09:56:05 -05:00
[V3 RPC] Swap back to initial RPC library and hook into core commands (#1780)
* Switch RPC libs for websockets support * Implement RPC handling for core * Black reformat * Fix docs for build on travis * Modify RPC to use a Cog base class * Refactor rpc server reference as global * Handle cogbase unload method * Add an init call to handle mutable base attributes * Move RPC server reference back to the bot object * Remove unused import * Add tests for rpc method add/removal * Add tests for rpc method add/removal and cog base unloading * Add one more test * Black reformat * Add RPC mixin...fix MRO * Correct internal rpc method names * Add rpc test html file for debugging/example purposes * Add documentation * Add get_method_info * Update docs with an example RPC call specifying parameter formatting * Make rpc methods UPPER * Black reformat * Fix doc example * Modify this to match new method naming convention * Add more tests
This commit is contained in:
21
tests/rpc_test.html
Normal file
21
tests/rpc_test.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<script src="https://code.jquery.com/jquery-2.2.1.js"></script>
|
||||
<script>
|
||||
var ws = new WebSocket("ws://localhost:6133");
|
||||
var message_id = 0;
|
||||
|
||||
ws.onmessage = function(event) {
|
||||
console.log(JSON.parse(event.data));
|
||||
}
|
||||
|
||||
function ws_call_method(method, params) {
|
||||
var request = {
|
||||
jsonrpc: "2.0",
|
||||
id: message_id,
|
||||
method: method,
|
||||
params: params
|
||||
}
|
||||
|
||||
ws.send(JSON.stringify(request));
|
||||
message_id++;
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user