Giter Site home page Giter Site logo

pychat's Introduction

pychat

A Python chat server, with multiple chat rooms, without any frameworks.

How to use:

  • Download and unzip all the files. You'll also need Python 3 installed. (You can download Python 3 from here)
  • To fire up server:

"host"(optional) is the ip address your server is running on. It'll default to '', i.e. accepting all connections.

python3 pychat_server.py [host]
  • To fire up client: "host"(not optional) should be the same ip address as the server
python3 pychat_client.py host

Once running client, you'll see prompts and instructions.

Example:

  • Text following "$" are command-line inputs
  • Text following ">" are user inputs within the client program
  • Text following "#" are comments

Server side:

$ python3 pychat_server.py 127.0.0.1
Now listening at ('127.0.0.1', 22222)

Client1: (create a new chat room "room1")

$ python3 pychat_client.py 127.0.0.1
Connected to server

Welcome to pychat.
Please tell us your name:

>joy
Instructions:
[<list>] to list all rooms
[<join> room_name] to join/create/switch to a room
[<manual>] to show instructions
[<quit>] to quit
Otherwise start typing and enjoy!

><list> # list all rooms
Oops, no active rooms currently. Create your own!
Use [<join> room_name] to create a room.

><join> room1
room1 welcomes: joy@('127.0.0.1', 61914)

><list> # list all rooms again
Listing current rooms...
room1: 1 player(s)

Client2 (joins room1 that Client1 just created and starts conversation)

 # open a new terminal
$ python3 pychat_client.py 127.0.0.1
Connected to server

Welcome to pychat.
Please tell us your name:

>jason
Instructions:
[<list>] to list all rooms
[<join> room_name] to join/create/switch to a room
[<manual>] to show instructions
[<quit>] to quit
Otherwise start typing and enjoy!

><list> # you should see room1 created by Client1
Listing current rooms...
room1: 1 player(s)

><join> room1
room1 welcomes: jason@('127.0.0.1', 61935) # you will also see this message in Client1's window

><list>
Listing current rooms...
room1: 2 player(s)

>hi # Client 1 will also see this, conversation started
jason@('127.0.0.1', 61935):hi

><join> room2 # switch to a new room
room2 welcomes: jason@('127.0.0.1', 61935) # you will see a "leaving message" in Client1's window

><list>
Listing current rooms...
room1: 1 player(s)
room2: 1 player(s)

>hi # Client1 will no longer see this

><quit>
Bye

To do:

  • Pass HOST as command-line args [DONE]
  • At first connect:
    • Prompt for username [DONE]
    • Prompt instructions [DONE]
  • Allow view/select/switch/quit rooms
    • view [DONE]
    • switch [DONE]
  • Main server displaying current activities [DONE]

pychat's People

Contributors

xysun avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.