SharedSpaces is a multiplayer showcase built by the VR Developer Technology team to demonstrate how you can quickly get people together in VR using our
Social APIs.
We achieve this with the following technologies:
Social APIs
To help communicate where people are in the Quest ecosystem, we created the concepts of
destinations and group presence. Destinations are points of interest that you define for your application. You can set a user’s group presence at one of those destinations, along with lobby and match identifiers.
Users can then invite their friends to join them using the system user interface. A notification pops up on the recipient’s headset and, if they accept the invitation, the application is launched with the sender’s group presence details.
In SharedSpaces, we only need the lobby and match session IDs to establish the communication paths at the transport layer.
Photon Realtime SDK
The Photon Realtime SDK is a popular transport layer used by many applications, in particular with the Unity game engine. Our developer relations team identified the need for more samples using the Unreal Engine with Photon, so we created a UE4 network driver for it, along with a UE4 plugin for the Photon Realtime SDK that can easily be reused in your own project.
Players that communicate need to be part of the same session (known as a Photon room). In the case of SharedSpaces, we simply use the player’s lobby or match session identifier as the room name. If you follow an invitation, you end up in the same room as the sender.
Unreal Engine + Unity
SharedSpaces was built using the Unreal Engine and then ported to Unity.
Both engines use a client-server architecture. Many applications require a dedicated server hosted in a datacenter. In this sample, we have opted instead to host the server on one of the headsets as it reduces our infrastructure needs. It also makes it trivial to start and stop servers as needed really fast.
The player selected to host the game server is the oldest member in the Photon room, a.k.a. the master client, and the other players connect to him as game clients. Packet routing is therefore done as follows:
At the transport layer, all players are connected to the Photon master server, which is a generic server (not a game server) that relays packets between them.
At the game level, the UE4/Unity server (hosted by the oldest player in the Photon room) receives packets from all players and replicates them down the other clients as needed.
Host migration, required whenever a master client leaves, is also demonstrated in SharedSpaces. When the player currently hosting a room leaves, the responsibility transfers to the new master client and all other players reconnect to him.
See a quick overview in our video demonstration:
The Design of SharedSpacesWe focused the design of SharedSpaces on group presence and networking, with a few connected levels that each correspond to a destination.

You start in a lobby (unless you are following an invitation to a match) and from there you can use portals to travel to different rooms. From each room you can open the roster and invite panels to send invitations to join you.
The Code Structure of SharedSpaces (UE4)Since we used Photon as our transport layer, we decided not to use the Oculus UE4 OSS (Online SubSystem) because the new destination and group presence functionality does not have its equivalent in that API. Instead we have built a new Oculus Platform Subsystem (a UE4 game instance subsystem) that is a thin layer between UE4 and our Oculus platform SDK. We also have built a second UE4 game instance subsystem to interface with the Photon SDK functionality that we use. Feel free to reuse these in your own projects.
Both are brought to life at the project level, especially in our SharedSpaces game instance blueprint.

Take the time to download and install the SharedSpaces project from one of our repositories. There is a lot to explore and understand both at the C++ and blueprint levels.
Code and DocumentationSharedSpaces is offered as a complete open source project with source code and documentation. Photon has granted us permission to redistribute their SDK with the project, which makes the sample self-contained.
Github
DemosSharedSpaces is also available on App Lab if you want to try it out without building the project yourself.