pdavis Posted May 25, 2017 Share Posted May 25, 2017 (edited) It is rough around the edges but is working none the less! This is a small footprint HTTP Server Plugin for LaunchBox. It contains image and web service APIs for accessing LaunchBox/BigBox properties. Provides the following: Standard HTTP interface for retrieving HTML pages for the current game. Any ImagePath property can be retrieved from the IGame object (Unbroken.LaunchBox.Plugins.Data.IGame.) by specifying /Image/ followed by the Image descriptor (the part preceding ImagePath). The page returned will refreshed every few seconds to keep the image current. * /Image/Back * /Image/Background * /Image/Box3D * /Image/Cart3D * /Image/CartBack * /Image/CartFront * /Image/ClearLogo * /Image/Front * /Image/Marque * /Image/PlatformClearLogo * /Image/Screenshot * /Manual - Not yet implemented JSON API for retrieving: * /StateManager (Unbroken.LaunchBox.Plugins.PluginHelper.StateManager) * /StateManager/* (Unbroken.LaunchBox.Plugins.PluginHelper.StateManager.*) * /StateManager/SelectedGames (Unbroken.LaunchBox.Plugins.Data.IGame) * /StateManager/SelectedGames/* (Unbroken.LaunchBox.Plugins.Data.IGame.*) * /StateManager/IsInGame The JSON being returned doesn't use envelopes and is subject to change until release. I'm open to suggestions on the formatting, structure, and interface in general. I just got this working for my test cases and it may hit a null reference and 404 pages when elements are empty or missing. Source: https://github.com/fpdavis/MarquesasServer To install copy the folder MarquesasServer that is located under the bin folder into your LaunchBox/Plugins folder. The server will begin running whenever LaunchBox is started. The first time you run it with the plugin a Windows security dialog will pop up asking if you want to allow it to connect to the network. You will need to select one of the two options presented, the option "Private networks, such as my home or work network will suffice". Once in LaunchBox you will see a new "Marquesas Server Admin" option under the Tools menu to manage the server. Edited May 25, 2017 by pdavis Font color was hiding text. Spacing issue. 2 Quote Link to comment Share on other sites More sharing options...
Nielk1 Posted May 26, 2017 Share Posted May 26, 2017 (edited) @pdavis I wrote my own little server but I spent all my time on the websocket portion to notify the client of events. It was quite tough to find a good websocket set and I nearly ended up coding my own before I found a small little library I could fork. I can see we both went for very different methods, where I went for a tiny little server wrapping the API and you went for a bit more of a structured wrapper with a sub-process. I'm not really feelin' it on this project though, and while I'm not sure if what I've done is compatible with your code I'd be glad to toss it to you to see if it can help. I feel like a tighter more reduced embedded system is the way to go, personally. If you're interested shoot me a PM and I'll throw you a zip of the code. This probably wasn't a waste on my part since I think I am going to switch to either custom UDP/TCP or websocks very similar to this for my 32bit interproc I currently use a named pipe for. Web requests are just so much easier to work with than blocking streams. I've attached a screenshot of what little I have so far. Edited May 26, 2017 by Nielk1 Quote Link to comment Share on other sites More sharing options...
pdavis Posted May 26, 2017 Author Share Posted May 26, 2017 I just checked in a new version of the server, it now offers a default page with links to make it easier to see what is available. A link to the default page is available in the plugin's admin menu as an ellipses button beside the port. Be warned that 404 pages are still returned when data isn't available (such as when no game is selected, but game information is requested or an image page is requested with no associated image). I originally envisioned this for use in displaying a Marquee image on a separate device such as an old tablet or PC dedicated to the task. This is what the /image pages are for. This will probably be the last update for about a week as I will be going on holiday. @Nielk1, I would love to take a look at the code, will shoot you a PM. I think there is plenty of room for a good set of web services, web sockets, and other much faster/tightly coupled options Quote Link to comment Share on other sites More sharing options...
Echoshard1 Posted May 26, 2017 Share Posted May 26, 2017 @pdavis Thank you! this is exactly what I needed for InfinityBox. Quote Link to comment Share on other sites More sharing options...
pdavis Posted May 27, 2017 Author Share Posted May 27, 2017 15 hours ago, Echoshard1 said: @pdavis Thank you! this is exactly what I needed for InfinityBox. @Echoshard1 Just let me know if there is anything specific you need and I will see about adding it. I changed the interface a bit in the last version and I still need to add proper header response codes for errors and null/empty responses. I believe all available information should be there and working though through the JSON WebAPI interface. I'm looking at the websocket code provided by @Nielk1 and will try to include a websocket interface as well. Quote Link to comment Share on other sites More sharing options...
Echoshard1 Posted June 5, 2017 Share Posted June 5, 2017 (edited) @pdavis everything seems to be working fine. The big problem was finding the right port for localhost I had a few things running. Now to get it to call the JSON correctly Edited June 5, 2017 by Echoshard1 Quote Link to comment Share on other sites More sharing options...
pdavis Posted June 5, 2017 Author Share Posted June 5, 2017 51 minutes ago, Echoshard1 said: @pdavis everything seems to be working fine. The big problem was finding the right port for localhost I had a few things running. Now to get it to call the JSON correctly Were you already running a web server on the default ports? I had not taken that into account. I more or less assumed this would be running on a dedicated or desktop PC without a web server. And for those that are running a web server they probably know what they are doing and can manually change the ports on the settings screen. I need to add code to check to see if the default ports are being used and inform the user if that is the case. Currently I am finishing up the manual/pdf support and adding binary retrieval for assets such as the manual and images. Currently images are only returned via a web page that refreshes whenever the game/image changes. Quote Link to comment Share on other sites More sharing options...
Echoshard1 Posted June 5, 2017 Share Posted June 5, 2017 (edited) 40 minutes ago, pdavis said: Were you already running a web server on the default ports? I had not taken that into account. I more or less assumed this would be running on a dedicated or desktop PC without a web server. And for those that are running a web server they probably know what they are doing and can manually change the ports on the settings screen. I need to add code to check to see if the default ports are being used and inform the user if that is the case. Currently I am finishing up the manual/pdf support and adding binary retrieval for assets such as the manual and images. Currently images are only returned via a web page that refreshes whenever the game/image changes. I was, In addition to a multiplayer system that used one of the ports. I just had to move stuff over, Can't wait for the documentation Thanks for all your work. This is a great way to get it to talk to other programs. Edited June 5, 2017 by Echoshard1 Quote Link to comment Share on other sites More sharing options...
pdavis Posted June 6, 2017 Author Share Posted June 6, 2017 I just checked in a new version with the following changes: Added Manual Support Added HTML Error pages Split up game heiarchy into SelectedGame (game being played?) vs SelectedGames (not being played, with possible multiple selections) Renamed SelectedGames to SelectedGame (without the S) Changed SelectedGame (previously SelectedGames) so the root /SelectedGame only returns information if one and only one game is selected Added SelectedGames (with the S) JSON responses to return information on multiple games Gracefully handles empty properties Added Binary support for selected game (you can now pull back images, manuals, music, video directly) Continued to refine default HTML page Main features yet to add: Add port use detection on startup Finalize naming convention for Auto Refreshing HTML pages (images/manual) - I still may change this to make it clearer Evaluate integration of Web Sockets code Need to continue to refine default html page and add documentation to it Complete Etag support for default html page (cache Page/MD5Sum) Add support for /Game/ID to pull back game information for games not selected but in XML files Memory/CPU profile I think an initial release (at least without web sockets) should be ready by next week. I want to get the Web APIs sorted out before tackling web socket support. Source: https://github.com/fpdavis/MarquesasServer 2 Quote Link to comment Share on other sites More sharing options...
Echoshard1 Posted June 7, 2017 Share Posted June 7, 2017 @pdavis It's working well with Unity's WWW can you add State Manager/GameTitle State Manager/PlatformTitle I am currently trying to figure out how to refresh my images. Knowing if the game Title changed would be most helpful Quote Link to comment Share on other sites More sharing options...
pdavis Posted June 21, 2017 Author Share Posted June 21, 2017 (edited) On 6/7/2017 at 1:38 PM, Echoshard1 said: @pdavis It's working well with Unity's WWW can you add State Manager/GameTitle State Manager/PlatformTitle I am currently trying to figure out how to refresh my images. Knowing if the game Title changed would be most helpful Sorry I missed your post. This information is actually available in: /selectedgame/title /selectedgame/platform Currently you will have to poll to see when the title changes. I actually use /selectedgame/id to detect a game change since it is guaranteed to be unique. I have not had a chance to roll in the Websocket code, that should be coming within the next couple of weeks. You can see all available information on the index page "/" The list of available properties are automatically updated based on what the LaunchBox API returns for the given objects (SelecteGames and StateManager). I just pass these properties straight through. I have not added any theme information. I believe this is available and shouldn't be hard to add. BTW, a new update is available with the following changes * Bug fixes * Added port use detection on startup * Reworked help to use Tool Tips * Added first time run dialog * Changed background color on autoloading pages to black * Enhanced the default index page with tabs and minor documentation, links now open in a new browser tab/window Edited June 21, 2017 by pdavis Hit enter too soon! Quote Link to comment Share on other sites More sharing options...
Echoshard1 Posted June 21, 2017 Share Posted June 21, 2017 Thanks, I will keep an eye out. My issue now is in VR loading all the art takes CPU bandwidth which can lag the headset. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.