GithubHelp home page GithubHelp logo

netty-chat's Introduction

netty-chat

采用websocket协议的实现了点对点,广播推送的聊天室项目。

服务端基于netty,客户端基于js+html。

服务端

服务端打包后的可执行jar为out\artifacts\netty_chat_jar下的netty-chat.jar

运行命令为java -jar netty-chat.jar

服务器启动后默认监听8080端口,也可以在命令中加入端口号例如java -jar netty-chat.jar 8888

默认创建两个账号:

用户名 密码 类型 功能
root root 管理员 可以向任意用户点对点发送消息
hyc hyc 普通用户 可以向所有用户群发消息

客户端

客户端直接打开src\main\resources下的html文件即可

  • chat.html聊天页
  • index.html登录页
  • register.html注册页

通信

通信消息使用JSON格式,所有消息均包含op属性用以区分消息的类型。例如

{
  "op":"login",
  "username":"root",
  "password":"root"
}

{
  "op":"updateChannel",
  "username":"root"
}

{
  "op":"getAllUser",
  "onlineUsers":[
    {
      "id":0,
      "username":"root"
    },
    {
      "id":1,
      "username":"hyc"
    }
  ]
}

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.