Riverhorse

Netplay

Up to four players can play over the network with rollback: the host starts a game and picks System > Host Netplay Session (or Host Netplay Session in the in-game panel); the others open the Netplay Lobby (Netplay in the toolbar, System > Netplay Lobby, or Netplay on the Big Picture home screen) and pick a session from the list of open sessions, or use Join by Code with the session code the host is shown. The lobby can also host a game from the game list. The host can list the session or keep it to people with the code, and can ask to accept each player. Everyone needs the same game in their game list, a BIOS with the same hash and the same Riverhorse version. For three or four players, the host turns on a multitap first (Settings > Controllers > Global Settings > Multitap Mode, port 1 for most games); players then take slots 1A-1D in the order they joined. From a frontend, start Riverhorse with -netplayhost <port> -- <game> or -netplayjoin <code|host:port> -- <game> (the game is used when it matches the host’s, otherwise the game list is searched), plus -netplaynick <name> and, to watch, -netplayspectate.

With -netplayevents, Riverhorse prints netplay events on stdout for a frontend to read, one line each, whether the session was started from the command line or the menus: netplay <event> key=value ..., with values percent-encoded (anything other than letters, digits and -._~: becomes %XX) and empty when unknown. Events:

  • hosting port=<udp port> code=<session code> serial=<game serial> title=<game title> nick=<host nickname> players=<max players> password=yes|no when a hosted session starts (code is empty without the relay)
  • player-joined nick=<nickname> player=<n> and player-left nick=<nickname> player=<n>, with players numbered from 1 (the host)
  • joined player=<n> when this instance joins someone else’s session
  • stopped when the session ends; a frontend should also treat the process exiting as the end of the session

Hosts can list their session publicly (“List in the session browser” in the host dialog, List Hosted Sessions in Big Picture, or -netplaypublic with -netplayhost; off by default). The relay serves the list as JSON over HTTP on the relay’s port number (TCP): GET /v1/sessions, optionally ?version=<Riverhorse version tag> to keep only sessions of that version (players can only join the same version). Each session has id and code (the session code, join with -netplayjoin <code>), nickname, serial, title, version, protocol, state_version, players, max_players, password and joinable (not full). Sessions leave the list when the host stops or stops answering the relay (30 seconds). Host addresses are never listed; joining goes through the relay.

Session codes come from a relay server, which introduces the players; they then connect directly, and only players whose routers block that keep going through the relay. Riverhorse uses a default relay; the host and join dialogs (or Settings > Essentials > Netplay in Big Picture) can turn the relay off or set your own as Custom Relay Server (host or host:port, the same for everyone). Without a relay, or when it can’t be reached, players join with the host’s address and UDP port (31200 by default), which must be reachable, so the host forwards it on their router when playing over the internet. To run a relay, build with -DBUILD_RELAY_SERVER=ON and start riverhorse-relay [port] (UDP 31210 by default) on a machine with that port open.