GithubHelp home page GithubHelp logo

anglc / nettychat Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thierryherrmann/2014-01-nettychat

0.0 2.0 0.0 196 KB

Simple asynchronous non blocking chat server/client based on Netty 4

Java 100.00%

nettychat's Introduction

Netty Chat

This is a simple asynchronous and non blocking chat server and client to play a bit with Netty 4 and Java.

Features:

  • account creation
  • login / logout
  • contact lists with offline invitations support
  • instant messages with offline messaging support
  • text UI or recordable commands

A permanent TCP connection is used similar to XMPP for all messages between clients and server. A fast custom encoder/decoder is used just as a demonstration of Netty capabilities.


Compile / run: mvn install

create DB tables: com.thn.netty.chat.server.store.JdbcUserStore

start the server: com.thn.netty.chat.server.Server

start a client: com.thn.netty.chat.client.Client


When starting the client:

0) Exit 
1) Create Account <username> <password>
2) Login <username> <password>
3) Logout 
4) Add Contact Invite <contactName>
5) Add Contact Response <userName> <accepted(true/false)>
6) Remove Contact <contactName>
7) Get Pending Contact Invitations 
8) Instant Message <recipient> <message>
9) Get Pending Messages 
10) Shutdown Server 

Alice logs in

2 Alice mypass

2014-01-08 12:34:08 INFO  MessageHandler:58 - cmd sent: LoginRequest[mType=LOGIN(2),mId=1,mUserName=UserName[mName=Alice],mPassword=mypass]
2014-01-08 12:34:08 INFO  MessageHandler:73 - msg received: OkResponse[mType=OK(15),mId=1]

Bob logs in

2 Bob mypass

2014-01-08 12:35:14 INFO  MessageHandler:58 - cmd sent: LoginRequest[mType=LOGIN(2),mId=1,mUserName=UserName[mName=Bob],mPassword=mypass]
2014-01-08 12:35:14 INFO  MessageHandler:73 - msg received: OkResponse[mType=OK(15),mId=1]

(log4j logs omitted below)

Bob sends add contact invitation to Alice

4 Alice

Alice who's online receives the invitation
Received contact request from UserName[mName=Bob]

Alice accepts the invitation: both users are contact of each other

5 Bob true

Bob receives Alice's response
Received contact response from UserName[mName=Alice]. Invitation accepted: true

Bob sends a message to Alice

8 Alice hello

Alice who's online receives the message
Received message from Bob: hello

Alice logs out and Bob sends a message to Alice

8 Alice Hi

Charlie logs in and sends a contact request to Alice who's offline

2 Charlie mypass

4 Alice

Alice logs in and fetches offline messages

2 Alice mypass

9

New messages: [MessageInfo[mSender=UserName[mName=Bob],mRecipient=<null>,mMessage=Hi]]

Alice fetches pending contact requests

7

These users ask permission to add you in their contact list: [UserName[mName=Charlie]]

nettychat's People

Watchers

James Cloos avatar  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.