Developing a plugin for tutman96's plugin system... I'm stuck #134
Unanswered
MaffooClock
asked this question in
Q&A
Replies: 1 comment 1 reply
-
So you'd need to implement two rpc handlers, one for the browser side (data channel) and the other for the plugin side. Then you'd need to figure out how to plumb them together such that the browser RPC knows which plugin to send the request to. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm working on a plugin that uses @tutman96's plugin system (discussion #9, PR #10). I understand that this is all new and not feature-complete, so I'm not asking for support, but I'd like to ask for a little guidance from Go developers who are clearly far more skilled than I am 😎
In discussion #101, I posited accessing the UART via the Extension Port. I built my own UART-to-RS232 cable (since the official serial console extension is not yet available) and was able to communicate with an external KVM via serial. Now, I'd like to build upon Mr. Tuttle's plugin system to make it easy for anyone with a serial-attached external KVM to control it from the JetKVM web UI.
I've been a professional software developer for over 15 years, but this is the first time I've used Go. So, I used Mr. Tuttle's Tailscale plugin as a starting point for my own. It was relatively easy to whittle off the Tailscale-specific stuff before adding in my own functionality with the serial library.
I've shared my work here: MaffooClock/jetkvm-plugin-serialkvm
I've been fairly successful, I think, despite my n00b status with Go. However, I've reached a point where I'm just stuck, and I haven't been able to figure out how to get past it. I'm hoping someone might be able to point out whatever I'm missing so I can get back on track.
This is what's in
/userdata/jetkvm/last.log
when enabling my plugin:...which all seems right to me. So far, so good.
Now, there's not yet a way to configure my plugin -- I see a "Plugin configuration coming soon" message in the plugin modal, and I know the final bullet in PR #10 says configuration management would be in a separate PR. Cool, no problem. I can manually supply a JSON configuration file for my plugin for testing, so it's not a barrier for my own development and testing.
My plugin is implements a
DoSwitchInput()
method, called when JSON-RPC gets a request forswitchInput
. Since there's not yet a way for a plugin to add it's own components to the web UI, the only way I know of to test this would be to manually dispatch a JSON-RPC message.So here's where things get sticky (for me)...
I initially assumed that the web UI used a WebSocket connection or maybe just a HTTP API for communicating with the
jetkvm_app
process, and that process used the Unix socket to the plugin to relay whatever was sent from the user's browser. I did not investigate this at all, I just made the assumption. 🤦🏻♂️ After wasting a lot of time trying to "test" JSON-RPC requests, I finally figured out that I was way off in left field. I won't even tell you how I was doing it because it is quite laughable how far off I was, haha. But it was a reasonable guess, and I had to start somewhere, however self-misguided it was.After taking some time to actually look at the JetKVM source and make an attempt to understand how it works, now I understand that the web client is using a data channel on the WebRTC session as the transport for JSON-RPC. Damn. I mean, neat! But also... damn.
All I wanted to do was just manually fire off some JSON-RPC requests to test my Go code, especially since there's not currently a way for my plugin to inject components into the web UI (like, a dropdown in the action bar). Now I know it's not as simple as using
curl
or anything similar to dispatch these JSON-RPC payloads.So, uh... how now brown cow?
So how would I send JSON-RPC requests for testing? I looked at trying to whip up a Node.js script to setup a WebRTC session so it could grab the data channel JSON-RPC, but that's already proving to be quite complicated. This is turning into a "the juice ain't worth the squeeze" situation, except I really would like to test JSON-RPC requests.
Or am I looking at this in completely the wrong way? Is there another way to test that my plugin will correctly receive and handle a JSON-RPC request for my
switchInput
method with ainputID
parameter without actually sending such a request?Beta Was this translation helpful? Give feedback.
All reactions