Skip to content

MirageNet/MultiplexSocketFactory

Repository files navigation

Documentation Discord release openupm

Plugin for Mirage.

Multiplex allows a server to run multiple sockets at once, this allows clients from multiple platforms to connect to the same game server.

Installation

openUPM

  1. Add openupm registry. Click on the menu Edit -> Project settings..., and add a scoped registry like so:
    Name: OpenUPM
    Url: https://package.openupm.com
    Scopes:
    • com.miragenet
  2. Close the project settings
  3. Open the package manager.
  4. Click on menu Window -> Package Manager and select "Packages: My Registries",
  5. select the latest version of MultiplexSocket and click install, like so:
  6. You may come back to the package manager to unistall MultiplexSocket or upgrade it.

Usage

  1. On the GameObject that contains your NetworkManager component, add the MultiplexSocketFactory component.
  2. Add other SocketFactory components that you want to use to the same or other GameObjects. For example, UdpSocketFactory and SteamSocketFactory.
  3. In the Inspector for MultiplexSocketFactory, expand the Factories list.
  4. Drag and drop your other SocketFactory components (e.g., UdpSocketFactory) into the list elements. The order of this list is important for clients.
  5. Finally, assign the MultiplexSocketFactory component to the Socket Factory field on your NetworkServer and NetworkClient components.

How it Works

The MultiplexSocketFactory behaves differently depending on whether it is running on a server or a client.

Server

When a server is started, the MultiplexSocketFactory iterates through the entire Factories list and creates a server socket for each one. This allows the server to listen for connections on multiple transports at the same time. For example, a single server can accept connections from local LAN players using UDP and from Steam friends using Steam's transport layer simultaneously.

Client

When a client starts, the MultiplexSocketFactory iterates through the Factories list in order and uses the first one that is supported on the current platform (IsSupported property returns true). This creates a fallback system. For example, if you place a Steam transport first in the list and a UDP transport second:

  • If the client has Steam running, it will use the Steam transport to connect.
  • If Steam is not running or not supported, the factory will fall back and try to use the UDP transport instead.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages