-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from cBournhonesque/cb/multi-transport
Enable using multiple concurrent ServerConnections
- Loading branch information
Showing
80 changed files
with
2,967 additions
and
1,876 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Multi connection | ||
|
||
|
||
In lightyear, the server can handle multiple connection protocol as the same time. | ||
This means that the server could: | ||
- open a port to establish steam socket connections | ||
- open another port for UDP connections | ||
- open another port for WebTransport connections | ||
- etc. | ||
|
||
and have all these connections running at the same time. | ||
|
||
You can therefore have cross-play between different platforms. | ||
|
||
Another potential usage is to have a "ListenServer" setup where a client acts as the "host": | ||
- the Client and the Server run in the same process | ||
- the Server has multiple connection protocols: | ||
- one is based on local channels to talk to the Client that is running in the same process | ||
- the other could be for example a UDP connection to allow other clients to connect to the server | ||
|
||
|
||
To achieve this, you can just provide multiple `NetConfig` when creating the `ServerConfig` that will be used to create the server. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,35 @@ | ||
# Netcode | ||
|
||
# Connection | ||
|
||
## Introduction | ||
|
||
I use the term 'netcode' to refer to code that creates an abstraction of a connection between two peers. | ||
|
||
Our transport layer only allows us to send/receive raw packets to a remote address. | ||
We want to be able to create a 'connection', which means: | ||
- sending some handshake packets | ||
- sending some keep-alive packets to check that the confirmation is still open | ||
- performing authentication | ||
But we want to be able to create a stateful 'connection' where we know that two peers are connected. | ||
|
||
To establish that connection, that needs to be some machinery that runs on top of the transport layer and takes care of: | ||
- sending handshake packets to authenticate the connection | ||
- sending keep-alive packets to check that the connection is still open | ||
- storing the list of connected remote peers | ||
- etc. | ||
|
||
In lightyear, it is possible to use different connection types, via the two traits | ||
`NetClient` and `NetServer`. | ||
|
||
Multiple implementations are provided: | ||
- Netcode | ||
- Steam | ||
|
||
I call this 'netcode' because I am using the [netcode.io](https://github.com/networkprotocol/netcode/blob/master/STANDARD.md) standard created | ||
by Glenn Fiedler (of GafferOnGames fame). | ||
|
||
## Netcode | ||
|
||
This implementation is based on the [netcode.io](https://github.com/networkprotocol/netcode/blob/master/STANDARD.md) standard created | ||
by Glenn Fiedler (of GafferOnGames fame). It describes a protocol to establish a secure connection between two peers, provided | ||
that there is a transport layer to exchange packets. | ||
|
||
For my purpose I am using [this](https://github.com/benny-n/netcode) Rust implementation of the standard. | ||
|
||
The standard provides: | ||
- authentication | ||
- encryption | ||
- etc. | ||
You can use the Netcode connection by using the `NetcodeClient` and `NetcodeServer` structs, coupled with any of the available | ||
transports (Udp, WebTransport, etc.) | ||
|
||
## Steam | ||
|
||
This implementation is based on the Steamworks SDK. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.cargo/config.toml → examples/bullet_prespawn/.cargo/config.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Settings( | ||
client: ClientSettings( | ||
inspector: true, | ||
client_id: 0, | ||
client_port: 0, // the OS will assign a random open port | ||
server_addr: "127.0.0.1", | ||
server_port: 5000, | ||
transport: WebTransport( | ||
// this is only needed for wasm, the self-signed certificates are only valid for 2 weeks | ||
// the server will print the certificate digest on startup | ||
certificate_digest: "1fd28860bd2010067cee636a64bcbb492142295b297fd8c480e604b70ce4d644", | ||
), | ||
// server_port: 5001, | ||
// transport: Udp, | ||
// server_port: 5002, | ||
// transport: WebSocket, | ||
), | ||
server: ServerSettings( | ||
headless: true, | ||
inspector: false, | ||
transport: [ | ||
WebTransport( | ||
local_port: 5000 | ||
), | ||
Udp( | ||
local_port: 5001 | ||
), | ||
WebSocket( | ||
local_port: 5002 | ||
) | ||
], | ||
), | ||
shared: SharedSettings( | ||
protocol_id: 0, | ||
private_key: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), | ||
) | ||
) |
Oops, something went wrong.