#Kerbal Web Program
1 messages · Page 2 of 1
eh 1 sec im sure I can find out
ok
vscode gets mad at me when I try using it
thats vscode
hmm
ok
thanks
what should I put on the left side?
I was thinking a vector of a rocket and staging info but idk where I'm gonna get a vector of a rocket that looks good from
up to you once we have a concept we can fix it and change it
no lol
damn
pdn only
well I'll use some sketchy web version then
why you need it?
switching one color in a vector to one that matches the theme
I use this its free and just as good
Paint.NET is free image and photo editing software for computers that run Windows.
This is a Paint.NET file type plugin for opening Scalable Vector Graphics (SVG) and its compressed variant SVGZ files. SVG elements can be rendered as a flat image file or each on a separate layer. The plugin is a wrapper around the SVG.NET Library which does the actual rendering. Current Latest ...
right now I have updated #1079614817083600906 I can focus on this again
yay
no gravity isnt working btw
wrong channel #1079265666961518655
send ur ksp2.log
turn no grav on and no aerodynamics. then turn grav back on. if you start falling it was working.
okie
any updates?
havent gotten a plane in the air yet lol
seems to be working for me (Ignore the hdr windows + screenshots never works with hdr)
haha my persistence paid off, I figured out how to code the streamdeck buttons with powershell. lol
XD
so dumb
POV: you're flying into the sun
for me it looks fine
huh weird
its called windows hdr
I wish that nvidia drivers supported hdr on linux bc then I'd use my dual boot more often
linux has the same hdr issue
right back to work on this
isnt it like 4am in the UK?
337
hmm
lol
can you like stream the view of your kerbals like as a jpeg that updates every second to the webui?
or is that too much work
add it to the api req
heres what I got finished today:
going to style the text a lot more
and fill up the center of the screen tommorow
ok cool
will find out how to get the mission time tomorrow. I have been looking for a few hrs now.
I'm having trouble coming up with things to put in the center so if you have any ideas lmk
gonna flesh out the parameters system a little bit and make a PR to discuss it
ok cool
Speed, TWR, atmospheric pressure, a navball image, fuel amounts
changing you both to outside collaborators as the repo is public. will remove some cost but access should be the same.
You pay for github enterprise?
no just team.
Alright
no
$4 per seat / month
Is it possible to get your heading/whatever makes the navball work though the API? I allready added an issue on github
well anything displayed on the screen I could get just have to find it
like the mission time that I cant seem to find but its there somewhere
im going to skip the mission time for now. and focus on the other api's that have been suggested.
issue #26 adding that stuff to the already existing getShiptelemetry
Ok
#21 added new api getShipOrbit
Thanks!
What does it return if you aren't in orbit
not tested it but its all been added to your frontend branch.
Other possible inspiration: https://apolloinrealtime.org/11/
Hey! I'm getting pretty close to having the nav screen done for the web UI but its going to be pretty painful to scale it to different screen sizes without angular or nuxt. Are you 100% we can't just have node as a dependency and/or bundle it in the mod?
that will be too complex for the end user (like if it fails to install).
I will take a look at it later to see what I can do about the scale since that should be an easy fix
Ok
We will go with vanilla css for the initial release and if you figure it out, we can make a separate version
eh?
What do you think @coral forge
also are cameras like a thing that is possible or no?
feedback is welcome and encouraged
no clue yet. depends if I can export an image
btw this is just the nav screen, there will also be other screens
next one im doing is control
where the planets are down the bottom maybe replace them with orbital data/quick info
alright
or charts
I was planning on plotting a dotted line that showed like what planet you were on a trajectory to
but either works
ah! great idea!
So the design is good though if I change the planet thing?
Bc then I'll finish up making everything actually work
um do any of the API's return what planet you are on a course to?
ye it looks great
or am I gonna have to calculate that myself
probably calculate it.
yay ✨ Math ✨
You do have a ton of orbital info from the orbit api
yeah I'll do that last
Having all planets displayed at once makes me think that a tab with them all would be cool to select one and show ships in its SOI accordingly, with some basic info like the status and altitude, if that's technically possible (then we could select the ships and get their specific details).
I was thinking the same thing but as a solarsystem map screen.
That works too, especially if the position of the bodies is real, that'd be awesome
should be doable, we have an api to grab all the bodies
Sweats nervously 👀
lol and im going to just pass that on to @hoary whale: add that to the github /s
I will do it dont worry lol.
I can if you want but that'll be an issue, not a PR :>
yeah
sure why not
Woops I posted with the API label instead of the enhancement, sorry
not connected view
thats good
mhmm
though it would be nice if you had a ping api request so it doesn't have to ask the game for the celestial body data of kerbin every 15s
The red theme is when there's no active connection?
yes
yes I should add an api for that
you know what to do @eager wyvern
what is this mod exactly for?
It'll allow showing some telemetry and general info on a secondary screen
||I'm secretely hoping that it'll allow sending instructions to KSP2 one day, maybe even some kOS instructions when/if kOS makes it to KSP2 (I hope so), and therefore play and follow one's missions from the web, remotely.||
first thing to do
deorbit the space station of my friend
it does have both get and set apis
Heres the current ones https://kerbalwebprogram.shadow.computer/view/14771341/2s93CRKBcn
heres ones that have been suggested https://github.com/Bit-Studios/KerbalWebProgram/labels/API
Any status updates on the apis?
been working on #1080370405421895701. any that you need doing now?
Not really, just was wondering
well I have added serverPing
Oh cool thanks
right now that #1080370405421895701 is at v0.1.0 I can focus on this again. Will get as many apis done today as I can.
shadow, youre gonna have as many mods as nertea if you keep it up
I just have too many ideas
I did also promise to make a mechjeb replacement so thats going to be fun.
🫡 🫡 🫡
Nertea nothin', they're on track to be the new LGG. 😛
How are you going to maintain all these projects lmao
I have done worse in the past.
I wont start any more until this one or parts manager is stable.
Is there updated API docs for it? I can't seem to find them
should be updated
seems like the api doc didnt update. But http://localhost:8080/docs auto gens the docs. Not finished but has the info you need
it has no parameters just set the action
like this?
does it actually return an actual round trip time or just an empty string
actually that would probrably be something that I'd have to calculate right
You get the SessionGuidString
anyone got any good playlist suggestions for listening to while programming?
Also we may have a problem
you know the spinning globe thing
It needs geoJSON to work, and I havent found a way to make it work with a png
so like
not sure if thats going to happen
we could use webgl. Just make a sphere and put the texture on top
ok cool
does the get world time return UTC or what
the docs page is not loading at all
It crashed my firefox lmao
uh I just tried to use the getUniverseTime but it didnt return anything
never mind mod wasn't updated 😛
kinda helps to do that
😄👍
Studing for exams tonight and tomorrow morning. I will continue working tomorrow night
Have you figured anything out with the mjpeg streams yet?
yes that parts easy. its just getting the data from the game that I need to figure out
I'd like to clarify a bit on what I was talking about in my PR in regards to how I think the API should work and my reasoning why as I don't think I explained it very well in the PR:
When I had originally suggested the API structure that we're currently using, the intention was that there would be 3 message types: response, error, and event. Response and error were meant to be direct responses to requests sent by clients, while events were for server-sent events. The reasoning behind this was to make routing these messages to handlers in clients easier, because you could look at the type and see "this is a response to my request" or "this is an event sent from the server." With the set up that you're trying to do now, the only way to route becomes checking for the existence of an ID, which may work fine in most cases, but can cause issues for reasons I'll get into in a second.
As for using type to be the actual data type of the response, I don't feel it makes much sense to send that with every single request as the response's data type can/should be documented separately, in a static manner just like the parameters. There are some very niche cases where the type might be different between requests, but in that case, the possible returned types can all be documented. Having the type there doesn't really do very much to help with parsing in the end as all that the type does is provide an arbitrary name that may mean one thing in one method and another thing in another. If two mods both add some method that returns a speed response, but one returns the speed as a vector and the other returns the speed as an absolute magnitude, it becomes useless to try to parse based on the presence of the speed type.
On the subject of what data is passed to method handlers and returned from them, I feel it's a massive mistake to treat method handlers like web server endpoints. Giving method handlers that kind of freedom will lead to huge inconsistencies in the API and make it a nightmare to parse for consumers. By far the biggest issue that can happen is someone completely ignoring the set API structure and deciding to respond in whatever way they want (adding some random ID, not setting the ID at all, etc.). If we want the API to be in any way consistent (and thus actually usable), we need to be a little more rigid in how we handle requests. What benefit does leaving the setting of the ID to the method handler provide? It will need to be set in every single solitary method handler anyway, so why not just handle it for them? And for the type, if we were using the type as it was intended to be used when I suggested this API structure, the type would be the same for every single method handler as well. Otherwise the type can be set based on what it's marked as statically in the method's metadata.
I understand that some of these changes would be considered breaking, but there isn't even a first release of this mod as far as I'm aware, so nothing is breaking until stuff is actually released. It's in my opinion that if this mod continues on this course, it's going to be much worse off in the long run than if we make these small changes to make it much more consistent now.
A better analogy for this mod is a web framework rather than a web server. What we're providing here isn't the equivalent of node's HTTPServer, we're providing something that's much more opinionated (or at least should be). Any mod can already add their own web server, it's built into the language/engine already. What we are doing is providing a consistent and extendable set of APIs so that mods can add the ability to access data via the web API without needing to do much themselves. By trying to not be opinionated like you are, it's making it much more work to write a simple method, and making it much more likely for the methods to be inconsistent with each other. Look at how many lines of code exist in each method handler that are exactly the same.
- Dictionary<string, object> response = new Dictionary<string, object>();
- CelestialBodyCore celestialBodyCore = GameManager.Instance.Game.CelestialBodies.Get(parameters["name"]);
- response.Add("body", celestialBodyCore.data);
+ ApiResponseData response = new ApiResponseData();
+ response.ID = request.ID;
+ response.Type = "response";
+ response.Data = new Dictionary<string, object>();
+ CelestialBodyCore celestialBodyCore = GameManager.Instance.Game.CelestialBodies.Get(request.parameters["name"]);
+ response.Data.Add("body", celestialBodyCore.data);
What was 3 lines before becomes 6, double the length. Why? Why do they need to handle that? It's ridiculous, frankly. And as someone who would be consuming the web API, the thought of mods being able to mess up the most basic parts of the requests is an absolute nightmare.
ok, so I figured out a way we can do websockets, although the downside is that I haven't yet found a way to have it listening on the same port as the normal HTTP server. We can use https://github.com/sta/websocket-sharp to do the server, and I made a quick little thing to test it, but I don't know enough about C# to have it handle stuff threaded/async
it does work though
WebsocketSharp can also act as the HTTP server 🙂
oh perfect
Anyone managed to get HTTPS working with a self-signed cert? UnityTLS rejects the certs because they're untrusted (as the server! wtf?) and ignores .NET overrides (ServicePointManager.ServerCertificateValidationCallback) so you'd have to add the cert to Windows' trusted certificate roots
which is very sketch
I'd recommend just adding a reverse proxy in front of it instead of trying to get unity to handle that
That's the fallback plan but that's extra setup and binaries to distribute with a mod :/
You probably wouldn't want the mod directly connected out anyway. Having a reverse proxy lets you do extra config and stuff. We wouldn't need to distribute one with the mod, just maybe add instructions or a link to a guide or something
That is true and I usually do prefer having nginx in between but in my case it's not so much about making the service public but about just needing HTTPS for a local network device because Chrome requires secure context for certain APIs
Hey folks, seems like an interesting project, I’m looking to start building out a TS library to let you control vessels (kRPC like) - I’ve read that you want to keep the backend pretty agnostic of the front, is this something I should be able to build off/with?
(First time delving into C# modding but senior full stack typescript dev for context)
Such a library would also serve as a great way to interact with the server from a typescript front end, for me the exciting part is being able to automate parts of the game.
Ive already started work on doing a TS library. I can push what I have so far to a GitHub repo if you want to contribute
Just tell me what I need to change
Hey, if you want to peek at a reference for using WebsocketSharp inside a mod, you might be interested in: https://discord.com/channels/1078696971088433153/1082042191653904475
I will take a look. will start working on this again after I have the parts manager finished.
since I think the code makes it a little clearer here, this is what my proposed structure for API messages was always intended to be (as TypeScript types):
export interface ApiErrorMessage {
ID: number;
Type: "error";
Error: Record<string, any>;
}
export interface ApiDataMessage<T = Record<string, any>> {
ID: number;
Type: "response";
Data: T;
}
export interface ApiEventMessage<T = Record<string, any>> {
Type: "event";
Name: string;
Data: T;
}
By having all messages follow this structure, it's easy to check type === "response" or type === "error" and handle it appropriately. Then, everything inside of Data is freeform to allow mods to respond with any data structure they want. (The error message data could also be under the Data key instead of the Error key, but that's beside the point)
@shrewd orbit Here's the repo with the little bit of stuff I got done the other day. There's a couple TODO items in the readme, but some of the stuff is also waiting on changes in the mod itself. https://github.com/Rodentman87/kwp-ts
Awesome! I literally just got my own version working (websocket server that can run commands), works great without a proxy or anything.
Will have to five into this and see if I can contribute directly, seems we all want the same thing 😉
yep, I think keeping things all together instead of duplicating work is the best way forward both for devs and for users
tomorrow after work I will start adding in the WebSocket support with https://github.com/sta/websocket-sharp
I can't wait for colonies, I want to make funny spreadsheets and stuff. Maybe a fake Kerbal delivery company with a tracker page that fakes like package tracking for the delivery routes
the delivery system is in the game could see what I can forward
#🔵ksp2-findings message
oh yeah I know it's there and will be there, just daydreaming about making funny UI for KSP
I need some general programming advice. I'm a part of a high school robotics team, and we have some serious lack of documentation and sometimes it's really confusing to fix things when they break or to implement new features. How could I/The programming team fix/make the documentation better
I'm asking you because our programming mentor doesn't do a lot of open source, and you sure have more experience than my 2 years of Java
😄
good rule of thumb is to reduce nesting and add comments explaining the purpose of functions
i think its said to avoid going more than like, 3 deep on nesting
also, if you're using JS add JSDoc comments to functions. If you're using Java, add JavaDoc comments to functions. Just adding those can go a long way to getting stuff much more usable
👍
This reminded me to clean up some deeply nested code for another project
This is the style guide I came up with for the repo. Any suggestions? https://github.com/5152Alotobots/5152_ChargedUp/wiki/Style-Guide
for that repo yes, also for stuff not relating to this project please move to #🟢general-chat
Ok
Btw i am almost done with the first iteration of the control screen. I'll send a image when it's done
cool
Made a PR to update the mod to SpaceWarp 0.4. I tested the changes and everything appears to be working fine, there's just some structural changes to the mod folder that need to be done to fit the BepInEx plugin format
approved.
yeet
hey i saw that there was talk about using websocket-sharp in ksp2, have you been able to get it working and is it server or client, im trying to get the client working but running in error 1006 which is a "low level error" with like no real ways to fix it (ran into this before). Im probably going to just implement with system.net.websockets but was interested to hear if other people where able to get it working
I got websocket-sharp working as a server. Didn't run into any issues at all
very weird, how did you install the package, just nuget and then put it alongside the mod dll in the mod folder?
I just manually downloaded the DLL and then put it alongside the mod dll in the folder, yeah
This was also running on space warp 0.2 without bepinex, and I haven't tested it again since then so I don't know if it still works. I assume it would though
yeah i wouldnt see how that could have change anything
Yeah I think so, I'm not at my PC to check
websocket-sharp provides the WebSocket protocol client and server.
It supports:
- RFC 6455
- WebSocket Client and Server
- Per-message Compression extension
- Secure Connection
- HTTP Authentication (Basic/Digest)
- Query String, Origin header and Cookies
- Connecting through the HTTP Proxy server
- .NET 3.5 or later (includes compatible)
okay no worries, ill try to download the dll manually instead of taking it from nuget and nuget folder, dont know how that could make a different but worth a try
didn't try the client
This is the one I used ^
If you're connecting HTTPS and either end is using a self signed cert then that's borked
hmm seem to be getting compatibility issues with that one
oh my mod seems to be on the wrong dotnet version, im on net standard 2 and example mod is on net472, that could explain some stuff
nice i have a connection now, thank yall for the help!
after work I will push an update for #1082724691724214393 and then the rest of the time will be dedicated to getting this into a release ready state.
Heres a road map, suggestions? changes?
(Expanded api from user suggestions: this will be in every update)
V0.1.0:
- Rest API
- Basic endpoints (aka whats on the github issues list)
- Inbuilt web hosting for your own frontend server
- Autogenerated api docs
- Expandable API with mods
V0.2.0:
- Websocket API
- More ship controls (websockets will give better realtime control)
- Basic frontend included
- Expanded api from user suggestions
V0.3.0:
- Parts [Camera, Locator]
- Part camera will allow for a video stream
- Part locator will allow for real time craft tracking (aka optional)
- Expanded api from user suggestions
I think that's pretty good 👍
want to try and get v0.1.0 out before this weekend.
I've been pretty inactive on the project because its finals week and our first robotics playoffs of this season is Thursday. Should be able to put some more attention into this next week
your stuff is in 0.2.0 so dont worry.
😯
when other mods add methods, I think it would be important to either encourage, or enforce method prefixes of the mod's modid, that way we wont run into any collisions where two mods try to register a method with the same name
Something else that I might add is a system to load in api extensions through sources that are not mods.
basically if you wanted to extend the api without having to create a mod or compiled code.
Will also help testing new apis as you wont need to reload the game
infact I might move the internal apis over to it
someone whos good at frontend development could probably improve this
Don't use var. Use const / let instead
And you don't need XMLHttpRequest. You can just use the buildin fetch api.
you could. thats just an example of how to use the api. you can use what ever system you like. I prefer XMLHttpRequest
Okay. I thought you wanted someone to review your code ¯_(ツ)_/¯
I more meant the style, I suck at frontend design. my area is backend.
But this is important because of scoping issues that may occur when using var.
var is completely obsolete in modern JS.
This is now working. Apis can now be loaded without needing a mod
Template api https://github.com/Bit-Studios/TemplateAPI
Contribute to Bit-Studios/TemplateAPI development by creating an account on GitHub.
just need to write up some docs for the mod its self.
Setup
Internal web server for hosting your own site - no third party software needed
API expansion - non mod
API expansion - mod
Forwarding to the internet - Nginx Proxy Manager + ssl + auth
wow I suck at writing docs
I can take a crack at it at some point
https://github.com/Bit-Studios/KerbalWebProgram/pull/36
New api loading system
Moved internal api into its own branch - should be in its own repo will move some time this weekend
Template api repo created
API doc generation
wiki docs in progress
Moved internal apis into a new branch (should really be a new repo) using the new api loading system, created template api repo as well https://github.com/Bit-Studios/TemplateAPI started work on th...
@eager wyvern or @livid shale could you please review this pull request so 0.1.0 can be released.
I would review, but I suck at c# so that's probably more of somethinng for maisy to do
Also I'm at robotics rn
Note for when webhooks get added.
Using the ingame message system will be the best option
Lots of options to pick from
Yep, there are a lot of messages (if thats what that image is)
and when WebSocket support is added they will be the first things that get api's
I was gonna add message abstraction to space warp then saw that and walked to the nearest rocket and left earth
lol
im probably going to find a way to do one manually and then template for the rest of them.
will finish off the wiki docs tomorrow. and hopefully the pull request goes through.
I think I'm going to completely rework the docs, and rather than them being a static page, just have it load the method data at runtime, that way we don't need to worry about load order of other mods affecting what ends up in the docs page.
and if for some reason things end up changing at run time it'll always be up to date
add that to v0.2.0
want to get 0.1.0 out early tomorrow to get user feedback on the current features and to find any bugs that have been missed.
hot reload is the first thing being added as its half done on my local branch
I would probably just use Swagger/OpenAPI to generate the API docs
less frontend to maintain
that wouldnt work with this.
Wiki has been made https://github.com/Bit-Studios/KerbalWebProgram/wiki
im not good at writing wikis so if you want to make it better please do.
W 👍
Updated the forum post with an API Extension list
You think it's possible to do something like a local web server that has a "command" station. Be able to display the map, vessel info mods and information windows on a separate monitor?
Haven't looked at your mod yet but definitely interested. Was thinking about API the other day
Would be cool to play the game while in flight basically from a custom command center on a local server and then just have the game monitor be visual camera only
yep you could do that
Did something similar to that.
That's crazy honestly I have like NASA control images going through my head for this. Very cool
Be able to actually like launch multiple missions and track all of them on another monitor and do large scale planning for concurrent missions and visually keep tabs on all of it
Status of colonies and production maybe when they come out
Well from a technical standpoint you can do anything with the mod. if it has a missing api you can add it through the api extension system
@feral pagoda
@eager wyvern is the one whos been working on the frontend, they would be the best person to speak to for that side of things.
Glad to lend a hand!
I am a little inactive right now because of my new classes and robotics, but I should be able to awnser any questions you have
Sorry for what may be a few dumb questions as I get my footing here:
How should I setup and check out the back end and front end? Do I install the mod and then clone the front end to begin testing them out, or should I clone the most recent backend version, etc? What's our dev environment supposed to look like, basically.
I'm playing around with the mod as is, and I'm starting to get the hang of it. I definitely like this.
For ingame web browser support I will be adding this to the project in one of the future updates https://github.com/Voltstro-Studios/UnityWebBrowser
case "jepg": ctx.Response.ContentType = "image/jpeg";
I guarantee you're not the first
oh well people can just use jpg since its the same thing.
this will be fixed in the next version. some time at the end of this month.
why an ingame browser?
if it's for loading the web page, I feel like that kinda defeats the purpose of having the server in the first place. Why use our worse-than-in-game web UI rather than just... the game which you currently have open and focused?
why not have an in game browser. not everyone has tons of screen space
I like this idea
EVE Online had that, it was not bad to keep game-related bookmarks out of the main OS environment. I could see myself using it for specific tools like a transfer planner.
hey, just shooting a message in here because im a bit confused, im making something kind of simular (not the same ofcourse) but im for example also calling stage from a remote, from the codebase (in the api branch) i found that this codebase just does "GameManager.Instance.Game.ViewController.GetActiveSimVessel().ActivateNextStage();" but when i do that, it works only when the resulting stage does not result into multple vessels, has this worked in testing?
i solved it myself with some reflection stuff after trying to do it cleaner for a couple of hours but im interested in hearing if there is another way and doing it more cleanly
the KWP standard api does it this way https://github.com/Bit-Studios/KerbalWebProgram/blob/12f8af402eaf5ca6e02df5636766ac6e3ccb21a0/ApiEndpointsBuiltIn.cs#L505
and that has been tested and works?
because that is what i tried and crashed my game, or does this require any other like setup for it to work well?
I use it here
well yeah but that would also work for me, like i said i crashed when the stage resulted in there being more active vessels, aka on a decouple. It might still work the same for you but i would like to get a distinct yes or no if that was tested and worked fine because then i can look into why it didnt work on my end
not tried, that was pre patch as well. ¯_(ツ)_/¯
okay fair, thank you for the response
sorry for not being much help.
well no it helps a lot because if it worked perfectly on your end i would have to look into why its so fucked on mine, and now i can kind of look at with more confidence that it might not work that way 🤷
btw in case you would be interested, im now just forcing the _stagingTriggered private variable in FlightInputHandler on true via reflection
just so no one gets confused. this is still being worked on
plan to get 0.2.0 out some time this weekend
rewrite of rest server
addition of UDP server
addition of WebSocket server
addition js modding
addition of ingame web browser with ability to "Merge" with ui. aka it will be seamless with the ui
Oh sat scanner included in update? 
I think your thinking of a different mod.
Oh that your other my bag sorry
*You're
