Skip to content

1MiKHalyCH1/ASVT-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Server for final task

This repository contains the python implementation of chat-server for final task.

How to run

Local run

cd server
python3 server.py

Requires python >= 3.5.

Server parameters can be configured in config.py

Docker run

docker-compose up --build -d

Server starts in docker (with default parameters in config.py)

Commands format

All commands to server should be packed:

<packed command length> + <command> 
[+ <packed argument length> + <argument>]
[+ ... ]

Exmaples:

users -> b'\x05\x00\x00\x00users'
register Bob -> b'\x08\x00\x00\x00register\x03\x00\x00\x00Bob'

Python example

Messages format

Messages shouldn't be greater then 60 characters!

Messages format looks similar to commands format:

<packed receiver username length> + <receiver username> + <packed message length> + <message>

Example:

'Hello, Bob!' for user 'Bob' -> b'\x03\x00\x00\x00Bob\x0b\x00\x00\x00Hello, Bob!'

Python example

Commands

After each command you would receive message.

  • register <username> - Registration on server. U can't use name of another user. Username shouldn't be greater then 8 symbols
  • users - Get list of online users.
  • send <formated message> - Message sending for specific user.
  • sendall <message> - Message sending for all online users.
  • receive - receive all messages that was sended for you. After this command all messages would be removed from server. Mesages are received in specific order:
  1) N = <messages count>
  2) Message 1
     .................................................
N+1) Message N
  • logout - Logout your user. After logouting your profile and your messages would be removed.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published