Skip to content

Commit

Permalink
impl AntiCheatServer and AntiCheatClient interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
3ddelano committed May 11, 2024
1 parent 80ed08e commit be521f1
Show file tree
Hide file tree
Showing 24 changed files with 1,691 additions and 234 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,9 @@ jobs:
- identifier: windows
name: 🏁 Windows
matchpattern: windows
- identifier: android-arm64
name: 🤖 Android arm64
matchpattern: android-arm64
- identifier: android-x86_64
name: 🤖 Android x86_64
matchpattern: android-x86_64
- identifier: android
name: 🤖 Android
matchpattern: android

steps:
- name: Merge artifacts for platform
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"files.associations": {
"*.rmd": "markdown",
"utility": "cpp",
"sstream": "cpp"
"sstream": "cpp",
"unordered_map": "cpp"
},
"grammarly.selectors": [
{
Expand Down
132 changes: 50 additions & 82 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@ Epic Online Services Godot (EOSG)
#### The [godot3-mono](https://github.com/3ddelano/epic-online-services-godot/tree/godot3-mono) branch is for Godot 3 Mono (C#) (un maintained)


## Features

- Authentication (Epic Games, Steam, Discord, Anonymous etc)
- Social Overlay on Windows
- Achievements
- Stats & Leaderboards
- Lobby, Sessions and Multiplayer
- Voice
- Metrics
- Mods
- Player/Title data storage
- Progression Snapshot
- Reports and Sanctions
- Ecommerce (Ecom Epic Games Store)
- AntiCheat

#### [View Current Project Status](#current-project-status)

## Support Development

#### Making this project took a lot of time and effort, reading the Epic Online Services documentation countless times and testing each method in Godot. I would really appreciate if you could support the project in any way.
Expand All @@ -28,7 +46,6 @@ Epic Online Services Godot (EOSG)
Join the Discord server for discussing suggestions or bugs: [3ddelano Cafe](https://discord.gg/FZY9TqW)


## [View Current Project Status](#current-project-status)

## [Demo Video (Youtube)](https://www.youtube.com/watch?v=ENyvF4yVjKg)
[Watch the playlist](https://www.youtube.com/playlist?list=PL5t0hR7ADzun5JYF4e2a2FtZEWYHxK83_)
Expand Down Expand Up @@ -340,84 +357,35 @@ Follow the instructions in [Running the service for local development](https://d

## Current Project Status

- Auth Interface
- [x] Implementation
- [x] Sample
- Achievements Interface
- [x] Implementation
- [x] Sample
- Connect Interface
- [x] Implementation
- [x] Sample
- CustomInvites Interface
- [x] Implementation
- [x] Sample
- Friends Interface
- [x] Implementation
- [x] Sample
- Stats Interface
- [x] Implementation
- [x] Sample
- UserInfo Interface
- [x] Implementation
- [x] Sample
- Leaderboards Interface
- [x] Implementation
- [x] Sample
- KWS Interface
- [x] Implementation
- [ ] Sample (No general access yet)
- Lobby Interface
- [x] Implementation
- [ ] Sample
- Metrics Interface
- [x] Implementation
- [x] Sample
- Mods Interface
- [x] Implementation
- [x] Sample
- P2P Interface
- [x] Implementation
- [ ] Sample
- PlayerDataStorage Interface
- [x] Implementation
- [ ] Sample
- Presence Interface
- [x] Implementation
- [x] Sample
- ProgressionSnapshot Interface
- [x] Implementation
- [x] Sample
- Reports Interface
- [x] Implementation
- [x] Sample
- RTC Interface
- [x] Implementation
- [ ] Sample
- Sanctions Interface
- [x] Implementation
- [ ] Sample
- Sessions Interface
- [x] Implementation
- [ ] Sample
- TitleStorage Interface
- [x] Implementation
- [ ] Sample
- UI Interface
- [x] Implementation
- [x] Sample
- Ecom Interface
- [x] Implementation
- [ ] Sample (Needs Epic Games Store access)
- AntiCheatServer Interface
- [ ] Implementation
- [ ] Sample
- AntiCheatClient Interface
- [ ] Implementation
- [ ] Sample
- Version Interface
- [x] Implementation
- [x] Sample
- Integrated Platform Interface
- [ ] Implementation
- [ ] Sample
- Completed with sample
- Auth Interface
- Achievements Interface
- Connect Interface
- CustomInvites Interface
- Friends Interface
- Stats Interface
- UserInfo Interface
- Leaderboards Interface
- Metrics Interface
- Mods Interface
- Presence Interface
- ProgressionSnapshot Interface
- Reports Interface
- UI Interface
- Version Interface

- Completed without sample
- KWS Interface
- Lobby Interface
- P2P Interface
- PlayerDataStorage Interface
- RTC Interface
- Sanctions Interface
- Sessions Interface
- TitleStorage Interface
- Ecom Interface
- AntiCheatServer Interface
- AntiCheatClient Interface

- Not completed
- Integrated Platform Interface
115 changes: 115 additions & 0 deletions sample/AntiCheatServerMain.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
class_name AntiCheatServerMain
extends Node

@onready var PRODUCT_NAME: String = Env.get_var("PRODUCT_NAME")
@onready var PRODUCT_VERSION: String = Env.get_var("PRODUCT_VERSION")
@onready var PRODUCT_ID: String = Env.get_var("PRODUCT_ID")
@onready var SANDBOX_ID: String = Env.get_var("SANDBOX_ID")
@onready var DEPLOYMENT_ID: String = Env.get_var("DEPLOYMENT_ID")
@onready var CLIENT_ID: String = Env.get_var("CLIENT_ID")
@onready var CLIENT_SECRET: String = Env.get_var("CLIENT_SECRET")
@onready var ENCRYPTION_KEY: String = Env.get_var("ENCRYPTION_KEY")

const PORT = 12345

func _ready() -> void:
print("AntiCheatServer _ready")

var init_success = await _load_and_init_sdk()
if not init_success:
return

_begin_session()
_start_server()

func _load_and_init_sdk() -> bool:
# -----
# EOS Setup
# -----

# Initialize the SDK
var init_opts = EOS.Platform.InitializeOptions.new()
init_opts.product_name = PRODUCT_NAME
init_opts.product_version = PRODUCT_VERSION
var init_res := EOS.Platform.PlatformInterface.initialize(init_opts)
var init_retry_count = 10
while not EOS.is_success(init_res) and init_retry_count > 0:
init_res = EOS.Platform.PlatformInterface.initialize(init_opts)
init_retry_count -= 1
await get_tree().create_timer(0.2).timeout

if not EOS.is_success(init_res):
print("Failed to initialize EOS SDK: ", EOS.result_str(init_res))
return false
print("Initialized EOS platform")

# Create platform
var create_opts = EOS.Platform.CreateOptions.new()
create_opts.product_id = PRODUCT_ID
create_opts.sandbox_id = SANDBOX_ID
create_opts.deployment_id = DEPLOYMENT_ID
create_opts.client_id = CLIENT_ID
create_opts.client_secret = CLIENT_SECRET
create_opts.encryption_key = ENCRYPTION_KEY
create_opts.is_server = true
create_opts.flags = EOS.Platform.PlatformFlags.DisableOverlay
var create_success: bool = EOS.Platform.PlatformInterface.create(create_opts)
var create_retry_count = 10
while not create_success&&create_retry_count > 0:
create_success = EOS.Platform.PlatformInterface.create(create_opts)
create_retry_count -= 1
await get_tree().create_timer(0.2).timeout
if not create_success:
print("Failed to create EOS Platform")
return false
print("Created EOS platform")

return true

func _begin_session():
IEOS.anticheatserver_interface_message_to_client_callback.connect(func(data):
print("--- AntiCheatServer: message_to_client_callback: ", data)
)

IEOS.anticheatserver_interface_client_action_required_callback.connect(func(data):
print("--- AntiCheatServer: client_action_required_callback: ", data)
)

IEOS.anticheatserver_interface_client_auth_status_changed_callback.connect(func(data):
print("--- AntiCheatServer: client_auth_status_changed_callback: ", data)
)

var begin_sess_opts = EOS.AntiCheatServer.BeginSessionOptions.new()
begin_sess_opts.register_timeout_seconds = 60
begin_sess_opts.server_name = "Godot 4.2 server"
begin_sess_opts.enable_gameplay_data = false

print("--- AntiCheatServer: begin_session: ", EOS.AntiCheatServer.AntiCheatServerInterface.begin_session(begin_sess_opts))

func _verify_id_token(peer_id: int, product_user_id: String, connect_id_jwt: String):
var id_token = EOS.Connect.IdToken.new()
id_token.json_web_token = connect_id_jwt
id_token.product_user_id = product_user_id

var verify_token_opts = EOS.Connect.VerifyIdTokenOptions.new()
verify_token_opts.id_token = id_token

EOS.Connect.ConnectInterface.verify_id_token(verify_token_opts)
print("--- AntiCheatServer: verify_id_token: ", await IEOS.connect_interface_verify_id_token_callback)

func _start_server():
multiplayer.peer_connected.connect(func(id: int):
print("--- AntiCheatServer:: peer_connected: ", id)
)
multiplayer.peer_disconnected.connect(func(id: int):
print("--- AntiCheatServer:: peer_disconnected: ", id)
)

var peer = ENetMultiplayerPeer.new()
peer.create_server(PORT)
multiplayer.multiplayer_peer = peer
print("Listening for clients on port: ", PORT)

func on_client_message_receive(peer_id: int, type: String, data: Dictionary):
if type == "register":
_verify_id_token(peer_id, data.local_user_id, data.jwt)
Loading

0 comments on commit be521f1

Please sign in to comment.