Мультиплеер: выделенный WebSocket-сервер, призраки других игроков
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
# Мультиплеер: деплой
|
||||
|
||||
## Сервер игры
|
||||
Выделенный сервер — тот же проект, запущенный headless (порт 9080, plain WebSocket):
|
||||
|
||||
godot --headless --path /путь/к/my-world res://Net/server.tscn
|
||||
|
||||
Пример systemd-юнита: `deploy/my-world.service`.
|
||||
|
||||
## nginx (TLS + статика)
|
||||
См. `deploy/nginx.conf`. Страница по https подключается к `wss://<домен>/ws`,
|
||||
nginx проксирует `/ws` на `127.0.0.1:9080`.
|
||||
|
||||
## Клиент
|
||||
Web-экспорт (пресет «Web») кладётся в корень сайта. Адрес сервера берётся из
|
||||
`window.location`, на десктопе — `ws://127.0.0.1:9080` или
|
||||
`godot -- --server-url=wss://example.com/ws`.
|
||||
@@ -0,0 +1,11 @@
|
||||
[Unit]
|
||||
Description=My World game server
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/godot --headless --path /opt/my-world res://Net/server.tscn
|
||||
Restart=always
|
||||
User=nobody
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,17 @@
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name example.com;
|
||||
# ssl_certificate / ssl_certificate_key — например, от certbot
|
||||
|
||||
root /var/www/my-world; # сюда экспорт Web (index.html, .wasm, .pck)
|
||||
index index.html;
|
||||
|
||||
location /ws {
|
||||
proxy_pass http://127.0.0.1:9080;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_read_timeout 1h;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user