Where to place some non-game-essential network code? (UE4.6)

About three weeks in to tinkering with UE 4.6 and loving it so far! Still trying to work out where some of the puzzle pieces fit, though. I know enough C++ to be dangerous, and I have a bit of a gift for jury-rigging inelegant and unstable solutions to problems that don’t actually exist. Once you understand that, everything else I ever post will start to make sense.

I’m putting together some code that can contact a web server to send/receive JSON data (get a list of public games, or add their server to the list of public games), while allowing servers to send regular updates while in play. It’s not required at all, but it’s there to make life a bit easier if someone wants to use it - click “connect” to join a game rather than have to get the IP and manually type it in, etc.

I’m also toying with the idea of allowing commands to be sent back to the server through this mechanism - so a server owner might want to change map through a web interface, they click a button, and the next time the server sends an update it gets the command included in the return data.

Getting the code to work is one thing, but I’ve just realised I have no idea where it should really live or tie into the game? I have an idea (because I don’t mean to ask you to do the hard work for me) but I would welcome comments on viability or better alternatives.

My idea so far is:

  • Put this all into a plugin
  • On program start, checks to see if plugin(s) available. Loops through plugins, programatically adds extra button on pre-game menu for each plugin
  • Plugin contains it’s own UI widget? (I’ve just realised while typing that I haven’t actually checked if this is possible. Bit of an oversight). If so, on clicking the menu button, Plugin UI is displayed - the menu built into the game doesn’t know or care what happens in the UI, it just knows that the plugin should have a UI to display.
  • User can access game lists/configure server publication etc through this UI.
  • Plugin will now do its thing in the background, occasionally pulling information from the game or calling functions in the game.
  • The game itself won’t need to know about how the plugin works and has no dependency on it, but will need to ensure that it provides an interface that a plugin could use.

Also, it would need to talk to GameMode, but presumably it needs to be persistent outside of GameMode - in fact I’m currently using GameMode to hold the pre-game menus so if I triggered this process entirely in the menu system then would it be brought to a halt when I changed GameMode to start a game?

But… am I completely wrong about how plugins work? Or am I using a horribly complicated approach when there is a much simpler and cleaner way to achieve the same goal?

Comments, even the rude ones, always appreciated. :slight_smile:

I think you don’t need to do that yourself.

There are online subsystems that do that. There are implementations for Steam, Xbox Live, etc… If you really want, it sounds like you may want to write a custom online subsystem if you have some custom backend. Shooter Game and Unreal Tournament should have samples for how to have menus for matchmaking.

Excellent! Completely missed that. Many thanks :slight_smile: