Skip to content

Commit

Permalink
Merge pull request #81 from channeldorg/master
Browse files Browse the repository at this point in the history
Merge pull request #80 from metaworking/release
  • Loading branch information
indiest authored Oct 9, 2024
2 parents 7c4cb3a + 8dfdbbb commit de422dd
Show file tree
Hide file tree
Showing 84 changed files with 2,957 additions and 1,989 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ channeld的最终目标是实现专用服务器的分布式组合,从而形成
* FSM-based message filtering
* Fanout-based data pub/sub of any type defined with Protobuf
* Interest management based on channel and data pub/sub
* Integration with the mainstream game engines ([Unity](https://github.com/metaworking/channeld-unity-mirror), [Unreal Engine](https://github.com/metaworking/channeld-ue-plugin))
* Integration with the mainstream game engines ([Unity](https://github.com/channeldorg/channeld-unity-mirror), [Unreal Engine](https://github.com/channeldorg/channeld-ue-plugin))
* [WIP] Backend servers load-balancing with auto-scaling

关键特性:
* 基于Protobuf的二进制协议,支持TCP、KCP、WebSocket
* 基于有限状态机的消息过滤
* 基于扇出的数据发布/订阅,支持任意Protobuf定义的数据类型
* 基于频道和数据发布/订阅的兴趣管理
* 接入主流游戏引擎([Unity](https://github.com/metaworking/channeld-unity-mirror), [Unreal Engine](https://github.com/metaworking/channeld-ue-plugin))
* 接入主流游戏引擎([Unity](https://github.com/channeldorg/channeld-unity-mirror), [Unreal Engine](https://github.com/channeldorg/channeld-ue-plugin))

## Performance 性能
channeld is aimed to support 10K connections and 100K mps(messages per second) on a single node (uplink + downlink), and 10M+ mps in a distributed system.
Expand Down Expand Up @@ -86,13 +86,13 @@ Use the input box at the bottom to send messages, to the GLOBAL channel by defau

## 4. The Unity tank demo
Follow these steps if the docker image has not been built for the tanks service yet:
1. Check out the [unity-mirror-channeld](https://github.com/metaworking/channeld-unity-mirror) repo
2. Create the Unity project following the [instruction](https://github.com/metaworking/channeld-unity-mirror#how-to-run-the-tank-demo)
1. Check out the [unity-mirror-channeld](https://github.com/channeldorg/channeld-unity-mirror) repo
2. Create the Unity project following the [instruction](https://github.com/channeldorg/channeld-unity-mirror#how-to-run-the-tank-demo)
3. Either build the Linux player from Unity Editor (Build -> Linux Server), or via the command: `Unity -batchmode -nographics -projectPath <PATH_TO_YOUR_UNITY_PROJECT> -executeMethod BuildScript.BuildLinuxServer -logFile build.log -quit`. The path to the Unity Editor needs to added to the PATH environment argument in order to run the command.
4. Build the docker image: `docker build -t channeld/tanks .`

Running the Unity tanks demo with Docker is similar to running the chat rooms demo. Navigate to the root of the repo and run the command:

`docker-compose up tanks`

Then you can the play the game in Unity Editor. See the [full instruction here](https://github.com/metaworking/channeld-unity-mirror#how-to-run-the-tank-demo).
Then you can the play the game in Unity Editor. See the [full instruction here](https://github.com/channeldorg/channeld-unity-mirror#how-to-run-the-tank-demo).
4 changes: 2 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"net/http"

"github.com/metaworking/channeld/pkg/channeld"
"github.com/metaworking/channeld/pkg/channeldpb"
"github.com/channeldorg/channeld/pkg/channeld"
"github.com/channeldorg/channeld/pkg/channeldpb"
"github.com/prometheus/client_golang/prometheus/promhttp"
)

Expand Down
19 changes: 18 additions & 1 deletion config/channel_settings_hifi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"DefaultFanOutIntervalMs": 20,
"DefaultFanOutDelayMs": 0,
"RemoveChannelAfterOwnerRemoved": false,
"SendOwnerLostAndRecovered": true,
"ACLSettings": {
"Sub": 3,
"Unsub": 3,
Expand All @@ -15,6 +16,7 @@
"DefaultFanOutIntervalMs": 20,
"DefaultFanOutDelayMs": 0,
"RemoveChannelAfterOwnerRemoved": true,
"SendOwnerLostAndRecovered": true,
"ACLSettings": {
"Sub": 2,
"Unsub": 2,
Expand All @@ -26,6 +28,7 @@
"DefaultFanOutIntervalMs": 20,
"DefaultFanOutDelayMs": 0,
"RemoveChannelAfterOwnerRemoved": true,
"SendOwnerLostAndRecovered": true,
"ACLSettings": {
"Sub": 3,
"Unsub": 3,
Expand All @@ -36,11 +39,25 @@
"TickIntervalMs": 20,
"DefaultFanOutIntervalMs": 20,
"DefaultFanOutDelayMs": 0,
"RemoveChannelAfterOwnerRemoved": true,
"RemoveChannelAfterOwnerRemoved": false,
"SendOwnerLostAndRecovered": true,
"ACLSettings": {
"Sub": 3,
"Unsub": 3,
"Remove": 2
}
},
"5": {
"TickIntervalMs": 20,
"DefaultFanOutIntervalMs": 20,
"DefaultFanOutDelayMs": 0,
"RemoveChannelAfterOwnerRemoved": true,
"SendOwnerLostAndRecovered": false,
"ACLSettings": {
"Sub": 3,
"Unsub": 3,
"Remove": 2
},
"DataMsgFullName": "tpspb.EntityChannelData"
}
}
7 changes: 6 additions & 1 deletion config/channel_settings_tps.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"DefaultFanOutIntervalMs": 20,
"DefaultFanOutDelayMs": 0,
"RemoveChannelAfterOwnerRemoved": false,
"SendOwnerLostAndRecovered": true,
"ACLSettings": {
"Sub": 3,
"Unsub": 3,
Expand All @@ -16,6 +17,7 @@
"DefaultFanOutIntervalMs": 20,
"DefaultFanOutDelayMs": 0,
"RemoveChannelAfterOwnerRemoved": true,
"SendOwnerLostAndRecovered": true,
"ACLSettings": {
"Sub": 2,
"Unsub": 2,
Expand All @@ -28,6 +30,7 @@
"DefaultFanOutIntervalMs": 20,
"DefaultFanOutDelayMs": 0,
"RemoveChannelAfterOwnerRemoved": true,
"SendOwnerLostAndRecovered": true,
"ACLSettings": {
"Sub": 3,
"Unsub": 3,
Expand All @@ -39,7 +42,8 @@
"TickIntervalMs": 20,
"DefaultFanOutIntervalMs": 20,
"DefaultFanOutDelayMs": 0,
"RemoveChannelAfterOwnerRemoved": true,
"RemoveChannelAfterOwnerRemoved": false,
"SendOwnerLostAndRecovered": true,
"ACLSettings": {
"Sub": 3,
"Unsub": 3,
Expand All @@ -52,6 +56,7 @@
"DefaultFanOutIntervalMs": 50,
"DefaultFanOutDelayMs": 0,
"RemoveChannelAfterOwnerRemoved": true,
"SendOwnerLostAndRecovered": false,
"ACLSettings": {
"Sub": 3,
"Unsub": 3,
Expand Down
7 changes: 6 additions & 1 deletion config/channel_settings_ue.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"DefaultFanOutIntervalMs": 20,
"DefaultFanOutDelayMs": 0,
"RemoveChannelAfterOwnerRemoved": false,
"SendOwnerLostAndRecovered": true,
"ACLSettings": {
"Sub": 3,
"Unsub": 3,
Expand All @@ -15,6 +16,7 @@
"DefaultFanOutIntervalMs": 20,
"DefaultFanOutDelayMs": 0,
"RemoveChannelAfterOwnerRemoved": true,
"SendOwnerLostAndRecovered": true,
"ACLSettings": {
"Sub": 2,
"Unsub": 2,
Expand All @@ -26,6 +28,7 @@
"DefaultFanOutIntervalMs": 20,
"DefaultFanOutDelayMs": 0,
"RemoveChannelAfterOwnerRemoved": true,
"SendOwnerLostAndRecovered": true,
"ACLSettings": {
"Sub": 3,
"Unsub": 3,
Expand All @@ -36,7 +39,8 @@
"TickIntervalMs": 20,
"DefaultFanOutIntervalMs": 20,
"DefaultFanOutDelayMs": 0,
"RemoveChannelAfterOwnerRemoved": true,
"RemoveChannelAfterOwnerRemoved": false,
"SendOwnerLostAndRecovered": true,
"ACLSettings": {
"Sub": 3,
"Unsub": 3,
Expand All @@ -48,6 +52,7 @@
"DefaultFanOutIntervalMs": 50,
"DefaultFanOutDelayMs": 0,
"RemoveChannelAfterOwnerRemoved": true,
"SendOwnerLostAndRecovered": false,
"ACLSettings": {
"Sub": 3,
"Unsub": 3,
Expand Down
16 changes: 16 additions & 0 deletions config/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
stream {
server {
listen 12108;
proxy_pass stream_backend;
proxy_buffer_size 64k;
health_check;
}

upstream stream_backend {
hash $remote_addr consistent;
server tps-channeld-1:12108; max_conns=512;
server tps-channeld-2:12108; max_conns=512;
server tps-channeld-3:12108; max_conns=512;
server tps-channeld-4:12108; max_conns=512;
}
}
9 changes: 5 additions & 4 deletions doc/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
- [x] Authentication
- [x] Channel ACL
- [x] DDoS Protection
- [ ] Health check
- [x] Spatial-based pub/sub
- [ ] Health check
- [ ] Disaster recovery
- [ ] Spatial-based load-balancing
- [ ] Distributed channels

Expand All @@ -25,11 +26,11 @@
- [x] Read/write the packet using Protobuf
- ~~[ ] Use [gogoprotobuf](https://github.com/gogo/protobuf) for faster marshalling/unmarshalling~~
- [x] Enable custom merge of channel data messages
- [ ] Non-reflection-based merge of channel data messages

# Tests
- [x] Unit tests
- [ ] Benchmark tests
- [ ] Scale tests
- [x] Benchmark tests

# SDKs
- [ ] Javascript SDK
Expand All @@ -49,7 +50,7 @@
- [ ] Complete the UI
- [ ] Unity tank game
- [x] Implement the C# client library
- [ ] Mirror Integration
- [x] Mirror Integration
- [x] Transport
- [x] SyncVar and NetworkTransform
- [x] Observers and Interest Management
Expand Down
4 changes: 2 additions & 2 deletions examples/channeld-ue-chat/chatpb/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package chatpb
import (
"errors"

"github.com/metaworking/channeld/pkg/channeldpb"
"github.com/metaworking/channeld/pkg/common"
"github.com/channeldorg/channeld/pkg/channeldpb"
"github.com/channeldorg/channeld/pkg/common"
)

func (dst *ChatChannelData) Merge(src common.ChannelDataMessage, options *channeldpb.ChannelDataMergeOptions, spatialNotifier common.SpatialInfoChangedNotifier) error {
Expand Down
6 changes: 3 additions & 3 deletions examples/channeld-ue-chat/go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module github.com/metaworking/channeld/examples/channeld-ue-chat
module github.com/channeldorg/channeld/examples/channeld-ue-chat

go 1.18

require (
github.com/metaworking/channeld v0.0.0-00010101000000-000000000000
github.com/channeldorg/channeld v0.0.0-00010101000000-000000000000
github.com/prometheus/client_golang v1.11.1
google.golang.org/protobuf v1.28.1
)
Expand Down Expand Up @@ -36,4 +36,4 @@ require (
golang.org/x/sys v0.18.0 // indirect
)

replace github.com/metaworking/channeld => ../..
replace github.com/channeldorg/channeld => ../..
8 changes: 4 additions & 4 deletions examples/channeld-ue-chat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"net/http"
"time"

"github.com/metaworking/channeld/examples/channeld-ue-chat/chatpb"
"github.com/metaworking/channeld/pkg/channeld"
"github.com/metaworking/channeld/pkg/channeldpb"
"github.com/metaworking/channeld/pkg/client"
"github.com/channeldorg/channeld/examples/channeld-ue-chat/chatpb"
"github.com/channeldorg/channeld/pkg/channeld"
"github.com/channeldorg/channeld/pkg/channeldpb"
"github.com/channeldorg/channeld/pkg/client"
"github.com/prometheus/client_golang/prometheus/promhttp"
"google.golang.org/protobuf/types/known/anypb"
)
Expand Down
18 changes: 18 additions & 0 deletions examples/channeld-ue-tps/Dockerfile-ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM golang:1.18.8

COPY . /channeld

WORKDIR /channeld/examples/channeld-ue-tps

ENV GOPROXY="https://goproxy.io"
RUN go get -d -v ./...
RUN go install -v ./...
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o . ./...
RUN apt-get -y update && apt-get -y install ethtool

COPY ./config /channeld/examples/channeld-ue-tps/config

EXPOSE 12108
EXPOSE 11288

ENTRYPOINT ["./channeld-ue-tps"]
2 changes: 1 addition & 1 deletion examples/channeld-ue-tps/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This folder only contains the files needed to run channeld with the setup of the Third Person demo in UE4.

To run the UE4 server and client, check out the code in:
https://github.com/metaworking/channeld-ue-demos
https://github.com/channeldorg/channeld-ue-demos
6 changes: 3 additions & 3 deletions examples/channeld-ue-tps/go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module github.com/metaworking/channeld/examples/channeld-ue-tps
module github.com/channeldorg/channeld/examples/channeld-ue-tps

go 1.18

require (
github.com/metaworking/channeld v0.0.0-00010101000000-000000000000
github.com/channeldorg/channeld v0.0.0-00010101000000-000000000000
github.com/prometheus/client_golang v1.11.1
github.com/stretchr/testify v1.8.1
go.uber.org/zap v1.19.1
Expand Down Expand Up @@ -40,4 +40,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/metaworking/channeld => ../..
replace github.com/channeldorg/channeld => ../..
10 changes: 6 additions & 4 deletions examples/channeld-ue-tps/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"fmt"
"net/http"

"github.com/metaworking/channeld/pkg/channeld"
"github.com/metaworking/channeld/pkg/channeldpb"
"github.com/metaworking/channeld/pkg/unreal"
"github.com/metaworking/channeld/pkg/unrealpb"
"github.com/channeldorg/channeld/pkg/channeld"
"github.com/channeldorg/channeld/pkg/channeldpb"
"github.com/channeldorg/channeld/pkg/unreal"
"github.com/channeldorg/channeld/pkg/unrealpb"
"github.com/prometheus/client_golang/prometheus/promhttp"
)

Expand All @@ -19,6 +19,8 @@ func main() {
channeld.InitLogs()
channeld.InitMetrics()
channeld.InitConnections(channeld.GlobalSettings.ServerFSM, channeld.GlobalSettings.ClientFSM)
channeld.SetChannelDataExtension[unreal.RecoverableChannelDataExtension](channeldpb.ChannelType_GLOBAL)
channeld.SetChannelDataExtension[unreal.RecoverableChannelDataExtension](channeldpb.ChannelType_SUBWORLD)
channeld.InitChannels()

channeld.InitSpatialController()
Expand Down
8 changes: 4 additions & 4 deletions examples/channeld-ue-tps/tpspb.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package main

import (
"github.com/metaworking/channeld/examples/channeld-ue-tps/tpspb"
"github.com/metaworking/channeld/pkg/channeld"
"github.com/metaworking/channeld/pkg/channeldpb"
"github.com/metaworking/channeld/pkg/unrealpb"
"github.com/channeldorg/channeld/examples/channeld-ue-tps/tpspb"
"github.com/channeldorg/channeld/pkg/channeld"
"github.com/channeldorg/channeld/pkg/channeldpb"
"github.com/channeldorg/channeld/pkg/unrealpb"
)

func InitTpsChannelDataTypes() {
Expand Down
10 changes: 5 additions & 5 deletions examples/channeld-ue-tps/tpspb/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package tpspb
import (
"errors"

"github.com/metaworking/channeld/pkg/channeld"
"github.com/metaworking/channeld/pkg/channeldpb"
"github.com/metaworking/channeld/pkg/common"
"github.com/metaworking/channeld/pkg/unreal"
"github.com/metaworking/channeld/pkg/unrealpb"
"github.com/channeldorg/channeld/pkg/channeld"
"github.com/channeldorg/channeld/pkg/channeldpb"
"github.com/channeldorg/channeld/pkg/common"
"github.com/channeldorg/channeld/pkg/unreal"
"github.com/channeldorg/channeld/pkg/unrealpb"
"go.uber.org/zap"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
Expand Down
2 changes: 1 addition & 1 deletion examples/channeld-ue-tps/tpspb/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package tpspb
import (
"testing"

"github.com/metaworking/channeld/pkg/channeld"
"github.com/channeldorg/channeld/pkg/channeld"
"github.com/stretchr/testify/assert"
"google.golang.org/protobuf/encoding/protojson"
)
Expand Down
Loading

0 comments on commit de422dd

Please sign in to comment.