Rooms with a short code over LAN and Steam for Unreal Engine.
Rooms with a short code over LAN and Steam for Unreal Engine.
NsSession gives multiplayer rooms with a 5-letter code, like KXQTP. The host opens a map and gets a code. A friend types the code and joins. A room is a Steam lobby when Steam runs, and a LAN session in other cases. When the nearby Steam search finds nothing, a second search looks in every region.
NsSession has no UI, no session browser, no player names, and no map setting. Your game gives the map, shows the status lines, and opens the title map after a leave.
-lanroom to test without Steam, or join an address directly.OnlineSubsystem, OnlineSubsystemUtils, and SteamSockets (Win64).OnlineSubsystemSteam in your project and set it up in DefaultEngine.ini. Steam rooms work on Win64 only.NsSession folder into the Plugins folder of your project."NsSession" to the dependencies of your game module in Build.cs.DefaultEngine.ini:[/Script/SteamSockets.SteamSocketsNetDriver]
NetConnectionClassName="/Script/NsSessionSteam.NsSteamNetConnection"
In Blueprint, get the subsystem with Get Ns Session Subsystem. Call Host Room with a map, or Join Room with a code. Bind On Room Status and show Get Status Text of each status.
In C++:
#include "NsSessionSubsystem.h"
// RoomMap is a TSoftObjectPtr<UWorld> property of the menu.
void UMyMenu::Host()
{
UNsSessionSubsystem::Get(this)->HostRoom(RoomMap.ToSoftObjectPath());
}
void UMyMenu::Join(const FString& Code)
{
UNsSessionSubsystem::Get(this)->JoinRoom(Code);
}
// Bound to OnRoomStatus. OnRoomStatus is a dynamic event, so this handler is a UFUNCTION.
void UMyMenu::HandleRoomStatus(const FNsRoomStatus& Status)
{
StatusText->SetText(Status.GetDefaultText());
}
| Module | Platforms | Content |
|---|---|---|
NsSession |
All | The subsystem, the status types, and the worldwide Steam search (Win64) |
NsSessionSteam |
Win64 | UNsSteamNetConnection |
UNsSessionSubsystem – The game instance subsystem that hosts, joins, and leaves rooms.HostRoom / JoinRoom / LeaveRoom – Open a room, join a room by code, and end the room on this machine.GetRoomCode / GetRoomNetwork – The code and the network of the current room.GetLastStatus / GetLastStatusText – The latest status, for a menu that reads it each frame.ConsumeLastFailure – The failure of a lost connection, one time.OnRoomStatus / OnRoomEntered – Each status step, and each load of a map as a listen server or client.FNsRoomStatus – Status, bFailed, RoomCode, Network, Detail, and GetDefaultText.UNsSteamNetConnection – The Steam net connection class.-lanroom always use LAN.