🚢
Airship
  • Getting Started
    • Welcome to Airship
    • Installing Airship
  • TypeScript
    • Overview
    • AirshipBehaviour
      • Adding Inspector Properties
      • AirshipSingleton
      • Using Component Decorators
      • Accessing Other Components
  • Publishing
    • Publish Game
    • Developer Console
  • Networking
    • Multiplayer
    • Local Server Mode
    • Network Signals
    • Network Functions
    • Network Identity
    • Network Transform
  • Input
    • User Input
      • Actions
      • Keyboard
      • Mouse
    • Proximity Prompts
  • Core Package
    • What is the Core Package?
    • Chat Commands
    • Inventory
    • Spawning Characters
    • Enable / Disable Core Features
  • Physics
    • Physics Settings
    • Physics Layers
  • Platform Services
    • Data Store
      • Locking
    • Cache Store
    • Leaderboards
    • Platform Inventory
    • Server Management
    • Server List
    • Server Transfers
    • Users
    • Parties
    • Matchmaking
    • External Services
  • CHARACTERS
    • Quick Configuration
    • Character Movement System
      • Character Movement Data
      • Character Movement Events
    • Character Camera
      • First Person Camera
      • Simple Usage
      • Camera Structure
      • Default Camera Modes
      • Disabling the Camera System
    • Character Animations
      • Character Blender Animations
      • Character Ragdoll
  • Accessories
    • Accessories Intro
    • Creating Accessories
    • Using Accessories
  • ANIMATIONS
    • Animation Events
  • Optimization
    • Live Game Profiler
    • Reducing Bundle Size
  • Game Settings
    • Game Visibility
  • Other
    • Project Status
    • FAQ
    • DataType Math
    • JS to Luau
    • Tags
    • Terrain
    • AirshipNetworkBehaviour
      • Lifecycle Events
      • ServerRpc
      • ObserversRpc
      • TargetRpc
    • VoxelWorld
      • Voxel World Getting Started
      • Voxel World Tips
      • Prefab Voxels
      • QuarterBlocks
    • Easy Helper Utils
      • Easy Motion
      • Easy Grid Align
      • Easy Look At
      • Easy Shake
      • Easy Destroy
Powered by GitBook
On this page
  • Listing a Server
  • Delist a Server
  • Retrieving the Server List
  • Common Patterns
  • Create a Match with a Lobby Only Friends Can Join
  1. Platform Services

Server List

Airship provides a basic server list that can be used to retrieve servers which may be accessible to a player in your game. The server list functions can be found in Platform.Server.ServerManager.

Listing a Server

A server can be listed at any time using the following code:

await Platform.Server.ServerManager.ListServer({
    // Name and description are optional
    name: "My Server",
    description: "A running server you can join",
})

You can call this again to update the name or description.

Delist a Server

If you want to remove a server from the list, you can do so at any time using the following code:

await Platform.Server.ServerManager.DelistServer();

Calling this function multiple times will have no effect.

Retrieving the Server List

The server list for a game can be retrieved on both the client and server side. Both the client and server have access to the full list using GetServerList(). This function returns the most populated servers first.

Additionally, the client has access to GetFriendServers() which returns any listed servers their friends are playing on.

Common Patterns

Create a Match with a Lobby Only Friends Can Join

// When the player clicks "create a lobby", create a server for them and move them
// to it.
const server = await Platform.ServerManager.CreateServer({
    sceneId: "LobbyScene",
    accessMode: AccessMode.FriendsOnly,
});
// We use "TransferToMatchingServer" to bypass the access rules for the owner. We
// won't do this for other players since we want to perform access checks for them.
await Platform.Server.Transfer.TransferToMatchingServer(player, {
    serverId: server.serverId,
});
// In our lobby scene on the new server, we can list the server when a player joins
const cleanUpConnection = Airship.Players.onPlayerJoined.Connect(async (player) => {
    // The first player to connect is the owner of the lobby
    owner = player;
    // Clean up the connection so we don't overwrite the owner when another
    // player joins
    cleanUpConnection();
    
    // List the server for the owner's friends to find
    await Platform.Server.ServerManager.ListServer({
        name: `${owner.username}'s Server`
    })
})

// We can also unlist the server when the owner starts the match
YourGameManager.onStartMatch.Connect(async () => {
    await Platform.Server.ServerManager.UnlistServer();
})
// Clients can retrieve servers their friends are on
const servers = await Platform.Client.ServerList.GetFriendServers();

// When they select their friend's lobby in a UI, send a network request to the
// server they are connected to requesting to transfer. (You'll have to set this up,
// see our docs on Network Functions)
Network.JoinLobby.client.FireServer(server.serverId);
// On the friends server, we get the client event and process it
Network.JoinLobby.server.OnClientEvent((player, serverId) => {
    // We can get the requested server's data to do additional checks
    // if we want to.
    const serverData = await Platform.Server.ServerManager.GetServer(serverId);
    if (!serverData || serverData.sceneId !== "LobbyScene") return;
    
    // Send the friend to the new lobby server
    await Platform.Server.Transfer.TransferToServer(friend, serverId);
})
PreviousServer ManagementNextServer Transfers

Last updated 9 months ago