Skip to content

Latest commit

 

History

67 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Simple Tweeter Server Handles Multi-Clients

Allows multi-clients to connect to server, subscribe and tweet messages with hashtags

Build Status MIT License Version

Table of Contents


Description

High Level Description of Implementation Idea

  • Client:

    • Client will have 2 threads: main thread takes user's input and processes commands, the other thread (client listener) keeps listening to the server to receive new messages (if there is new message with hashtags that client has subscribed).
    • When connecting to the server, the client will create a client listener which sends sign-in request to server. If sign-in successful, client listener will keep listening to that socket connection to receive messages from the server. Then client will create another socket connection to send request to server with new user's command input.
    • Client saves all messages receive from server. Those messages can be retrieved with command timeline
    • All the input arguments will be checked before processing the commands.
    • The client will clean up all data before exiting.
  • Server:

    • When client first signs in, if there is no existing username => client logins successfully. The server will save the socket connection to broadcast messages later.
    • Whenever accepting a new connection, server creates a new thread to handle that client.
    • If server receives a new tweet, it will broadcast the message to all subscribers by using saved socket connection (server saved them when clients first signed in)
    • The server will clean up all data before exiting.

Installation

  • Require Python >= 3.6 Version
  • Download or git clone the project

Clone

  • Clone this repo to your local machine using https://github.com/nhat-lan/networking.git

Setup

update and install this Python 3 version

$ brew update && upgrade
$ brew install python3

Features

Users can send tweet with one or multiple hashtags, get all messages receive from server (messages related to hashtags that user subscribed to), retrieve online users list, subscribe hashtag, unsubscribe hashtag.


Usages

Move to the top directory of the project.

Running Server:

$ python3 ttweetser.py <portnumber>

Running Clients:

$ python3 ttweetcli.py <serverip> <portnumber> <username>

Client can use commands such as tweet, subscribe, unsubscribe, timeline, getusers, exit.

  • tweet "<message>" <hashtag>
$ tweet "Here is my mesage" #myhashtag1
$ tweet "Here is my mesage" #myhashtag#anotherHashTag
  • subscribe <hashtag>
$ subscribe #myhashtag1
$ subscribe #ALL
  • unsubscribe <hashtag>
$ unsubscribe #myhashtag1
$ unsubscribe #ALL
  • timeline
$ timeline
  • getusers
$ getusers
  • exit
$ exit
Note:
  - Server IP: `0.0.0.0` or `127.0.0.1`
  - Message format:
    + Message is always between `""`, within range [1,150] characters
  - Hashtag format:
    + Hashtag is within range [1,] not included `#`, can only included alphanumeric characters ([a-zA-Z0-9])
    + Hashtag #ALL is reserved, so client cannot tweet with this hashtag
  - Username format:
    + Can only included alphanumeric characters ([a-zA-Z0-9])
  - Subscribe:
    + Client can only subscribe one hashtag at a time
    + Clients can only subscribe up to 3 hashtag (unless unsubscribe previous subscribed hashtags)
  - Client will be removed from server when exiting. Server only store active clients.

Contributing

  • work was allocated equally between all team members

Step 1

  • Option 1

    • 🍴 Fork this repo!
  • Option 2

    • 👯 Clone this repo to your local machine using https://github.com/nhat-lan/networking.git

Step 2

  • HACK AWAY! 🔨🔨🔨

Step 3

  • 🔃 Create a new pull request using https://github.com/nhat-lan/networking/compare/.

Team

  • Nhat Lan Le Tu

githublinkedinemail

  • Uyen Dinh

githublinkedinemail

  • Kiet Tran

githublinkedinemail


Support

Please reach out to our team!


License

License

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages