Skip to content

Commit c2339f5

Browse files
committed
docs: adding usage docs to readme
1 parent 21749dc commit c2339f5

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,19 @@ Multiplex allows a server to run multiple sockets at once, this allows clients f
2424

2525

2626
## Usage
27-
27+
1. On the `GameObject` that contains your `NetworkManager` component, add the `MultiplexSocketFactory` component.
28+
2. Add other `SocketFactory` components that you want to use to the same or other `GameObject`s. For example, `UdpSocketFactory` and `SteamSocketFactory`.
29+
3. In the Inspector for `MultiplexSocketFactory`, expand the `Factories` list.
30+
4. Drag and drop your other `SocketFactory` components (e.g., `UdpSocketFactory`) into the list elements. The order of this list is important for clients.
31+
5. Finally, assign the `MultiplexSocketFactory` component to the `Socket Factory` field on your `NetworkServer` and `NetworkClient` components.
32+
33+
## How it Works
34+
The `MultiplexSocketFactory` behaves differently depending on whether it is running on a server or a client.
35+
36+
### Server
37+
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.
38+
39+
### Client
40+
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:
41+
- If the client has Steam running, it will use the Steam transport to connect.
42+
- If Steam is not running or not supported, the factory will fall back and try to use the UDP transport instead.

0 commit comments

Comments
 (0)