Skip to content

Working app#37

Open
jayantna wants to merge 1 commit intowhamcloud:mainfrom
jayantna:main
Open

Working app#37
jayantna wants to merge 1 commit intowhamcloud:mainfrom
jayantna:main

Conversation

@jayantna
Copy link
Copy Markdown

Video Demo (Loom screen recording)

Architecture Overview

  • Asynchronous Runtime: Powered by Tokio, allowing many clients to be handled concurrently without blocking.
  • Networking: Built on TCP Sockets (TcpListener on the server and TcpStream on the client).
  • Clap: A simple CLI interaction with the chat app.

Server

  1. Broadcast: Uses tokio::sync::broadcast to create a message channel. Any message sent to the transmitter (tx) is instantly cloned to every active receiver (rx).
  2. Concurrency: Each new client is tokio::spawn into its own asynchronous task, ensuring one slow client doesn't lag the others.
  3. Event Multiplexing: Uses tokio::select! in the client handler to listen simultaneously for:
    • Incoming Traffic: Reading typed messages from the client's TCP socket.
    • Outgoing Traffic: Receiving broadcasted messages from the channel to write back to the client.

Client

  1. Handshake: Sends a username immediately upon connection for the server to identify the sender.
  2. Bi-directional Stream: Splits the TcpStream into a Reader (for receiving server messages) and a Writer (for sending user input).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant