diff --git a/4players.gif b/4players.gif deleted file mode 100644 index 3a9de88..0000000 Binary files a/4players.gif and /dev/null differ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 680a573..4d9b383 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,16 +3,27 @@ This page provide technical information to facilitate future maintenance of the project. - [Contributing](#contributing) + - [Building the frontend and the backed](#building-the-frontend-and-the-backed) - [Building backend from sources](#building-backend-from-sources) - - [Deployments methods](#deployments-methods) - - [Use CLI in console mode](#use-cli-in-console-mode) - - [Deploy the game for Web based access](#deploy-the-game-for-web-based-access) - [Information for developers](#information-for-developers) - - [Client console](#client-console) + - [Web client](#web-client) - [Server](#server) - [High level design](#high-level-design) - [Low level design](#low-level-design) - [Debug log](#debug-log) + - [Code coverage](#code-coverage) + +## Building the frontend and the backed + +Prerequisites: + +- install node.js and ionic CLI +- install go 1.21 + +```bash +make ionic-build +make docker-build +``` ## Building backend from sources @@ -38,107 +49,18 @@ go vet -v ./... go test -v ./... ``` -## Deployments methods - -The are different ways of deploying this client/server game: - -- using CLI in console mode (recommended for development or native client on a wide range of platforms), -- with Web based access for better user experience (recommended for end users), - -### Use CLI in console mode - -The same binary file is used to start the server and console clients. Various platform are supported. See [latest release page](https://github.com/fc92/poker/releases/latest) for more details. For example to use the Windows terminal natively without Docker use the corresponding binary file. - -Start a single server instance (dedicated for one team): - -- using default websocket: - -```bash -./poker server -subcommand 'server' - websocket: localhost:8080 -``` - -- or specifying the websocket to open: - -```bash -./poker server -websocket 127.0.0.1:7878 -subcommand 'server' - websocket: 127.0.0.1:7878 -``` - -When the server is started, start a client for each player. It must be able to communicate with the server. - -- example of client specifying a player name and the websocket value: - -```bash -./poker client -name Player1 -websocket 127.0.0.1:7878 -subcommand 'client' - name: Player1 - server websocket: 127.0.0.1:7878 -``` - -- example of client using a generated name and default websocket: - -```bash -./poker client -subcommand 'client' - name: snowy-cloud - server websocket: localhost:8080 -``` - -Each player can navigate the client console and send commands using keyboard and mouse. - -NB: in mobaXterm mouse events are not always correctly handled - -This binary file is located in `/poker` in the docker image and can be used with `docker run` on a limited number of supported platforms. - -### Deploy the game for Web based access - -In production the docker image is used to provide both server and client processes. This is described in the [README page](/README.md). - -For development outside of docker the manual steps to work with the `poker` binary are described here. This binary is the result of the `go build -o poker cmd/poker.go` command and can also be found in `/poker` of the docker image. - -Prerequisite: server with docker and [tty2web](https://github.com/kost/tty2web) binary (tested on Linux x86_64). - -To simplify the user experience it is recommended to: - -- start the server in a docker container: - -```bash -docker run -p 192.168.0.1:8080:8080/tcp ghcr.io/fc92/poker:main /poker server -websocket 8080 -``` - -to expose the server on address 192.168.0.1 port TCP 8080 - -- provide user access in a web browser using [tty2web](https://github.com/kost/tty2web): - -```bash -tty2web --title-format Poker --permit-arguments -a 192.168.0.1 -p 8081 -w docker run -it --rm ghcr.io/fc92/poker:main /poker client -websocket 192.168.0.1:8080 -``` - -so that users can connect to to join the game in a browser with player name *Mary*. - -There are multiple benefits with this tty2web deployment method: - -- users only need a web browser with proper network access to play the game, -- users can play on platforms that are not natively supported like iOS or Android, -- the server and each player process run inside a restricted container for security. - - ## Information for developers This section provides technical information for developers. -### Client console +### Web client -Each player starts a console client to join the team server and play the game. +Each player starts vue.js application in a browser. Client main features: -- [X] display available commands -- [X] allow mouse and keyboard user inputs -- [X] user defined or generated player name +- [X] enter player name +- [X] choose poker room - [X] commands: quit game, start new vote, send vote, modify vote, close the vote session - [X] display vote progress during vote session - [X] display distribution of votes when vote session is closed @@ -180,15 +102,14 @@ A `Participant` can be updated by local user actions or updates sent from the se ### Low level design -Server and console client are written in pure Go language. - -The software is packaged as a single binary file for each supported platform. The same file is used with different parameters to start a server or a client instance from a text console. +Server is written in pure Go language. Client is written in TypeScript using vue.js and ionic framework. -It should be possible to write other client implementations using other languages supporting websocket and JSON. The focus of this project is pure GO so far. +The software is packaged as a single binary file for each supported platform. ## Debug log Server debug logs can be activated using the `-debug` flag ### Code coverage + ![Codecov graph](https://codecov.io/github/fc92/poker/graphs/sunburst.svg?token=R4OZKBC13P "Codecov graph") diff --git a/README.md b/README.md index bd437cd..cd3e2dd 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,6 @@ - [poker](#poker) - [Game description](#game-description) - [Install](#install) - - [Standard deployment](#standard-deployment) - - [Custom HTTP port deployment](#custom-http-port-deployment) ## Game description @@ -22,36 +20,11 @@ - Vote values are revealed only when the vote session is closed, and the vote distribution is displayed. - Players can join or leave at any time. -Early version in console: -![short demo](4players.gif) - ## Install The most common usage is to deploy: -- deploy a container for one poker room on server side, +- the helm chart and a tls secret `poker-tls` in a Kubernetes namespace, - use a modern browser on client side to join the room for the game. -### Standard deployment - -- Server using default HTTP port 8081: - -```bash -docker run -p 8081:8081 -td ghcr.io/fc92/poker:main -``` - -- Browser URL to connect as player *Mary*: -`http://server_ip:8081/?arg=-name&arg=Mary` - -### Custom HTTP port deployment - -The port can be modified, to add a second poker room for example: - -- Server using non default HTTP port 8083 and room name "TeamOne": - -```bash -docker run -p 8083:8083 -td ghcr.io/fc92/poker:main ./clients.sh 8083 TeamOne -``` - -- Browser URL to connect as player *Mary*: -`http://server_ip:8083/?arg=-name&arg=Mary` +The list of rooms can be customized using the ROOM_LIST environment variable of the container.