Jump to content
LaunchBox Community Forums

Marquesas Server (HTTP Server Plugin for LaunchBox)


Recommended Posts

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.

MarquesasServerAdmin.PNG

Edited by pdavis
Font color was hiding text. Spacing issue.
  • Like 2
Link to comment
Share on other sites

@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.

unknown.png

Edited by Nielk1
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...
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.

Link to comment
Share on other sites

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 by Echoshard1
Link to comment
Share on other sites

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

 

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...
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 by pdavis
Hit enter too soon!
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...