Skip to content

carlolalu/basic-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Objectives

Implement a chat server (step by-step)

  • IMPLEMENT graceful shutdown (done for the client, but not yet perfect: after control-C it is necessary to press also enter)

  • add a GUI, so that you can separate output and input in the clients. On the server side could be cool to have a tree showing what is happening inside the server in a structured way.

  • add a general tests (recall that to see the output you might want to use the arg --nocapture) that on different screens executes the server adn a number of clients which connect to it and chat among themselves

  • implement basic level for an admin authentication: if one gives a specific commands and provides the right password, it can control the server (only one person per time must be granted such access)

  • add some security and cryptography. Just the basics.

T. hot recommendations

  • shutdown issue: the sync functions should be called with a spawn blocking.

  • framing and buffering: what happens when a message is longer than 250 chars? There is a tokio_util instrument about framing and buffering.

Developer's guide

channels and strings

  • Concept: the client side sends and receives these structs: struct Message { username: String, content: String }, but this structure on the client side is wrapped inside a Dispatch: struct Dispatch {userid: SomeType, msg : Message }. This so that I do not have to implement any protocol to let a client find a unique username, but at the same time, the clienthandler can avoid to send to its client the messages sent by himself, and instead filter out the ones sent by eventual people with the same name (by exploiting the id).

  • convert Vec -> String by String::from_utf8()? e String -> Vec by string.as_bytes()

  • data is NOT cleaned from new line characters \n

About

A basic chat realised with rust and tokio.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages