Fabriciope / cli_chat

Chat usando o protocolo TCP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CLI CHAT 💬

banner-cli-chat

🌐 Documentation translated into English

Este projeto Ă© um chat usando o protocolo TCP.

Bibliotecas utilizadas

  • Testify: pacote usado para fazer os asserts nos testes.
  • Go terminal size: usado para identificar quando o tamanho do terminal Ă© alterado para fazer a adaptação da interface.
  • Strip ANSI: utilizado para remover cĂłdigos de escape ANSI das strings usando regex.

InstruçÔes passo a passo para usar o chat localmente

⚠ Para rodar o servidor tcp e o client serĂĄ necessĂĄro ter o docker instalado em sua mĂĄquina para subir os contĂȘineres com suas respectivas imagens, portanto se estiver usando windows basta usar o terminal linux com o wsl, caso jĂĄ esteja em um ambiente linux, simplismente execute os comandos em uma nova sessĂŁo do terminal.

Primeiramente faça o clone do projeto, antes verifique se tem o git instalado.

git clone https://github.com/Fabriciope/cli_chat.git cli-chat && cd cli-chat

Agora execute os scrips abaixo para a criar a rede utilizada na comunicação entre os clientes e o servidor, e tambĂ©m criar as imagens que serĂŁo utilizadas para subir os contĂȘineres do servidor e do cliente.

./scripts/create_network.sh && \
./scripts/build_images.sh

Inicialize o servidor tcp executando o camando abaixo no seu terminal. Se vocĂȘ quiser subir o servidor em background para nĂŁo precisar ver os logs adicione a flag -d ao comando para que o contĂȘiner inicie em modo detached.

docker run -it --network cli_chat --name cli_chat-server tcp_chat-server:prod

Captura de tela de 2024-04-22 23-18-10

Para iniciar o chat do lado do cliente basta executar o comando abaixo trocando o <n> por algum nĂșmero que vocĂȘ queira identificar aquela instĂąncia, faça isso a cada novo contĂȘiner de cliente que vocĂȘ iniciar, os nĂșmeros nĂŁo podem se repetir pois nĂŁo pode haver dois contĂȘineres com o mesmo nome.

Execute o comando abaixo em uma nova sessĂŁo do terminal para cada novo usuĂĄrio do chat que vocĂȘ queira entrar.

docker run -it --network cli_chat --name cli_chat-client<n> tcp_chat-client:prod

docker-run-client

Execute o comando abaixo em uma nova sessĂŁo do terminal pra ver todos os contĂȘineres ativos no momento, tanto o do servidor quanto dos usuĂĄrios que vocĂȘ iniciou.

docker container ls

container-ls

Caso tenha terminado a execução do servidor ou de algum usuĂĄrio e queira subir o contĂȘiner novamente, execute o comando abaixo substituindo o <container name> pelo nome do respectivo contĂȘiner que vocĂȘ quer reiniciar, para visualizar os nomes execute o comando anterior novamente.

docker start -i <container name>



Contato: fabricioalves.dev@gmail.com


Documentation translated into english

This project is a chat using the TCP protocol.

Libraries used

  • Testify: package used to make asserts in tests..
  • Go terminal size: used to identify when the terminal size is changed to adapt the interface.
  • Strip ANSI: used to remove ANSI escape codes from strings using regex.

Step-by-step instructions for using chat locally

⚠ To run the tcp server and the client you will need to have docker installed on your machine to upload the containers with their respective images, so if you are using windows just use the linux terminal with wsl, If you are already in a Linux environment, simply run the commands in a new terminal session.

First clone the project, first check if you have git installed.

git clone https://github.com/Fabriciope/cli_chat.git cli-chat && cd cli-chat

Now run the scripts below to create the network used in communication between clients and the server, and also create the images that will be used to upload the server and client containers.

./scripts/create_network.sh && \
./scripts/build_images.sh

Initialize the tcp server by running the command below in your terminal. If you want to run the server in the background so you don't need to see the logs, add the -d flag to the command so that the container starts in detached mode.

docker run -it --network cli_chat --name cli_chat-server tcp_chat-server:prod

Captura de tela de 2024-04-22 23-18-10

To start the chat on the client side, simply execute the command below, replacing the <n> with any number that you want to identify that instance, do this for every new client container you start, the numbers cannot be repeated as there cannot be two containers with the same name.

Run the command below in a new terminal session for each new chat user you want to join.

docker run -it --network cli_chat --name cli_chat-client<n> tcp_chat-client:prod

docker-run-client

Run the command below in a new terminal session to see all currently active containers, both the server and the users you started.

docker container ls

container-ls

If you have finished running the server or a user and want to upload the container again, run the command below replacing <container name> with the name of the respective container you want to restart, to view the names run the previous command again.

docker start -i <container name>



contact: fabricioalves.dev@gmail.com

About

Chat usando o protocolo TCP


Languages

Language:Go 98.6%Language:Dockerfile 1.0%Language:Shell 0.4%