Commit graph

111 commits

Author SHA1 Message Date
Sergey Stepanov
cb968d782a
Show rooms in the list 2023-10-21 02:37:44 +03:00
Sergey Stepanov
fb5d8c216b
Don't change players when there is no game 2023-10-18 21:46:33 +03:00
Sergey Stepanov
1b82c48dc1
Don't show the share popup message 2023-10-18 20:37:57 +03:00
Sergey Stepanov
226bb0384e Remove Quit notification 2023-09-24 14:22:34 +03:00
Sergey Stepanov
8703309090 Remove old ping/pong handlers 2023-09-24 14:22:34 +03:00
Sergey Stepanov
992b6e06da Hide sys info in the frontend 2023-09-16 20:12:24 +03:00
Sergey Stepanov
f2d21c67dc
Partial fix for convoluted game list ext info bug 2023-09-01 22:55:18 +03:00
Sergey Stepanov
c063dd92c6 Remove unused CSS rules 2023-06-16 14:12:41 +03:00
Sergey Stepanov
6106eee97e Update game list module 2023-06-16 14:12:41 +03:00
Sergey Stepanov
2e1c837643 Show systems in the interface 2023-06-16 14:12:41 +03:00
Sergey Stepanov
5b4f74e2b7
Notify users when there are no gaming slots 2023-05-21 13:54:21 +03:00
Sergey Stepanov
624eecd4e8
Show errors when ICE fails 2023-05-17 08:57:16 +03:00
Sergey Stepanov
d985440930
Center menu item 2023-05-12 21:20:08 +03:00
Sergey Stepanov
3815e18027
Remove the hack involving the /static route 2023-05-03 11:11:08 +03:00
Sergey Stepanov
2add701c39
Update game picker interface 2023-04-27 19:50:07 +03:00
Sergey Stepanov
f7d8a5dc50
Revert opts z-index 2023-04-27 16:27:05 +03:00
Sergey Stepanov
ed21e32b1f
Speedup item pick 2023-04-27 16:15:09 +03:00
Sergey Stepanov
bee6192894
Use old font 2023-04-27 15:15:37 +03:00
Sergey Stepanov
e50dc102bb
Make game pick time consistent 2023-04-27 14:49:54 +03:00
Sergey Stepanov
30584b3faa
Make game picking less ugly 2023-04-27 14:26:16 +03:00
Sergey Stepanov
dc48c93804
Hide load/save by default 2023-04-27 13:33:07 +03:00
Sergey Stepanov
0c532a7f93
Fix moving settings 2023-04-27 13:31:17 +03:00
Sergey Stepanov
c4895fae84
remove unselect from js menu items 2023-04-27 13:27:34 +03:00
Sergey Stepanov
e17a358ade
Fix circle pad layering text blur 2023-04-27 13:06:43 +03:00
Sergey Stepanov
bb9f904104
Fix menu select side blur 2023-04-27 13:05:12 +03:00
Sergey Stepanov
40bd57c9a0
Remove not needed browser prefixes 2023-04-27 12:28:28 +03:00
Sergey Stepanov
ea3263ca6c
Remove unselected 2023-04-27 12:24:07 +03:00
Sergey Stepanov
b6d6e464ed
Optimize images 2023-04-26 20:11:08 +03:00
Sergey Stepanov
494979cf38
Optimize images 2023-04-26 20:08:20 +03:00
Sergey Stepanov
229cd4044c
Fix broken warning in the wrtc js module 2023-04-24 14:16:25 +03:00
Sergey Stepanov
3bd32715cb
Remove unused fonts 2023-04-23 19:55:39 +03:00
Sergey Stepanov
3c2c24038d
Hack 2023-03-29 13:03:31 +03:00
sergystepanov
3bd959b4ef
Refactored v3 (#350)
This PR contains refactored code.

**Changelog**
- Added new net code (the communication architecture was left intact).
- All network client IDs now have custom type `network.Uid` backed by github.com/rs/xid lib.
  ```
  The string representation of a UUID takes 32 bytes, and the new type will take just 16.
  Because of Golang JSON serialization problems with omitting zero-length empty slices (it can't) 
  and the need to use UID values as map keys (maps don't support slices as keys), 
  IDs are stored as strings (for now).
  ```
- A whole new WebSocket client/server implementation was added, as well as a new communication layer with synchronous and async call handlers.
  - WebSocket connections now support dedicated Ping/Pong frames as opposed to original ping text messages.
  - Used Gorilla WebSocket library doesn't allow concurrent (simultaneous) reads and writes, so this part was handled via send channel synchronization.
- New API structures can be found in the `pkg/api` folder.
- New communication protocol can be found in the `pkg/com/*` folder.
- Updated communication protocol is based on JSON-encoded messaging through WebSocket and has the following structure:
  ```
  Packet
    [id] string — a globally unique identification tag for the packet to track it trough a chain of requests.
    t uint8 — contains packet type information (i.e. INIT_PACKET, SDP_OFFER_PACKET, ...).
    [p] any — contains packet data (any type).

  Each packet is a text message in JSON-serialized form (WebSocket control frames obviously not).
  ```
  ```
  The main principle of this protocol and the duplex data exchange is:
  the one who initializes connection is called a client, and 
  the one who is being connected to is called a server. 
  With the current architecture, the coordinator is the server, the user browsers and workers are the clients.

            ____           ____
           ↓    ↑         ↑    ↓
     browser ⟶ coordinator ⟵ worker
       (c)          (s)         (c)

  One of the most crucial performance vise parts of these interactions is that 
  all the server-initiated calls to clients should be asynchronous!
  ```
  - In order to track synchronous calls (packets) with an asynchronous protocol, such as WebSocket, each packet may have an `id` that should be copied in all subsequent requests/responses.
  - The old `sessionID` param was replaced by `id` that should be stored inside the `p` (payload) part of the packet.
- It is possible to skip the default ping check for all connected workers on every user connection and just pick the first available with the new roundRobin param in the coordinator config file `coordinator.roundRobin: true/false`.
- Added a dedicated package for the system API (pkg/api/*).
- Added structured logging system (zerolog) for better logging and cloud services integration.
- Added a visual representation of the network message exchange in logs:
  ```
  ...
  01:00:01.1078 3f98 INF w → c Handshake ws://localhost:8000/wso
  01:00:01.1138  994 INF c ← w Handshake localhost:8000
  01:00:01.1148  994 INF c ← w Connect cid=cep.hrg
  01:00:01.1158  994 DBG c     connection id has been changed to cepl7obdrc3jv66kp2ug cid=cep.hrg
  01:00:01.1158 3f98 INF w → c Connect cid=cep.2ug
  01:00:01.1158  994 INF c     New worker / addr: localhost, ...
  01:00:01.1158 3f98 INF w     Connected to the coordinator localhost:8000 cid=cep.2ug
  01:00:02.5834  994 INF c ← u Handshake localhost:8000
  01:00:02.6175  994 INF c ← u Connect cid=cep.hs0
  01:00:02.6209  994 INF c     Search available workers cid=cep.hs0
  01:00:02.6214  994 INF c     Found next free worker cid=cep.hs0
  01:00:02.6220  994 INF c → u InitSession cid=cep.hs0
  01:00:02.6527  994 INF c ← u WebrtcInit cid=cep.hs0
  01:00:02.6527  994 INF c → w ᵇWebrtcInit cid=cep.hrg
  01:00:02.6537 3f98 INF w ← c WebrtcInit cid=cep.2ug
  01:00:02.6537 3f98 INF w     WebRTC start cid=cep.2ug
  ...
  ```
- Replaced a monstrous Prometheus metrics lib.
- Removed spflag dependency.
- Added new `version` config file param/constant for compatibility reasons.
- Bump the minimum required version for Go to 1.18 due to use of generics.
- Opus encoder now is cached and the default config is 96Kbps, complexity 5 (was 196Kbps, 8).
- Changed the default x264 quality parameters to `crf 23 / superfast / baseline` instead of `crf 17 / veryfast / main`.
- Added a separate WebRTC logging config param `webrtc.logLevel`.
- Worker now allocates much less memory.
- Optimized and fixed RGB to YUV converter.
- `--v=5` logging cmd flag was removed and replaced with the `debug` config parameter.


**Breaking changes (migration to v3)**
- Coordinator server API changes, see web/js/api/api.js.
- Coordinator client event API changes:
  - c `GAME_PLAYER_IDX_CHANGE` (string) -> `GAME_PLAYER_IDX` (number)
  - c `GAME_PLAYER_IDX` -> `GAME_PLAYER_IDX_SET`
  - c `MEDIA_STREAM_INITIALIZED` -> `WEBRTC_NEW_CONNECTION`
  - c `MEDIA_STREAM_SDP_AVAILABLE` -> `WEBRTC_SDP_OFFER`
  - c `MEDIA_STREAM_CANDIDATE_ADD` -> `WEBRTC_ICE_CANDIDATE_RECEIVED`
  - c `MEDIA_STREAM_CANDIDATE_FLUSH` -> `WEBRTC_ICE_CANDIDATES_FLUSH`
  - x `MEDIA_STREAM_READY` -> **removed**
  - c `CONNECTION_READY` -> `WEBRTC_CONNECTION_READY`
  - c `CONNECTION_CLOSED` -> `WEBRTC_CONNECTION_CLOSED`
  - c `GET_SERVER_LIST` -> `WORKER_LIST_FETCHED`
  - x `KEY_STATE_UPDATED` -> **removed**
  - n `WEBRTC_ICE_CANDIDATE_FOUND`
  - n `WEBRTC_SDP_ANSWER`
  - n `MESSAGE`
- `rtcp` module renamed to `webrtc`.
- Controller state equals Libretro controller state (changed order of bits), see: web/js/input/input.js.
- Added new `coordintaor.selector` config param that changes the selection algorithm for workers. By default it will select any free worker. Set this param to `ping` for the old behavior.
- Changed the name of the `webrtc.iceServers.url` config param to `webrtc.iceServers.urls`.
2023-01-09 23:20:22 +03:00
Sergey Stepanov
8025cc1d87
Make client ICE logging a bit clearer 2022-07-13 00:00:54 +03:00
Sergey Stepanov
be0e00c7bf
Use display: none in the hide function, so it won't take any space 2022-04-18 22:47:35 +03:00
Sergey Stepanov
ed60ccf41e
Fix visibility of the help overlay 2022-04-18 19:13:26 +03:00
Sergey Stepanov
4baccc4701
Allow adjusting log levels on the fly 2022-04-11 17:46:10 +03:00
Sergey Stepanov
3bbf075f92
Log lines in the browser console 2022-04-11 09:16:08 +03:00
Sergey Stepanov
63d8a0354c
Remove unused CSS in the worker list element 2022-04-09 10:46:10 +03:00
Sergey Stepanov
fac6cc4495
Generate xIds on the worker's side 2022-04-09 10:27:04 +03:00
Sergey Stepanov
c190177955
Show active workers in the debug mode 2022-04-08 20:11:28 +03:00
sergystepanov
9ad3c98a7d
Rework worker selection feature (#365)
We add a new option for manual worker or machine (server with multiple workers) select, depending on the new coordinator option `coordinator.debug` which by default allows machine selection.
2022-04-07 21:04:30 +03:00
Sergey Stepanov
12352d5677
Open GitHub links in a new tab 2022-03-22 22:08:36 +03:00
Sergey Stepanov
3292964f01
Fix pubsub listeners indexing overlap 2022-01-02 06:58:55 +03:00
Sergey Stepanov
24ff0f2ea2
Close WebRTC connections on disconnect
Not closing RTCPeerConnection and co will cause eventually high processor load in Chrome.
Also, Chrome has some GC issues related to WebRTC, see: https://bugs.chromium.org/p/chromium/issues/detail?id=825576.
2021-12-17 16:10:51 +03:00
Sergey Stepanov
535177bd46
Fix recording handling when it's disabled 2021-12-05 22:11:29 +03:00
sergystepanov
1271aa8438
Game recording support (#356)
This feature adds the ability to record game sessions as raw a/v media files.
2021-12-04 14:20:38 +03:00
Sergey Stepanov
b916b0bf19
Add RTT stats 2021-09-02 23:58:05 +03:00
Sergey Stepanov
e7a2b6a33e
Prevent client favicon requests 2021-08-30 16:30:03 +03:00
Sergey Stepanov
9289d9390b
Update stats module 2021-08-28 15:06:51 +03:00