Giter Club home page Giter Club logo

websocket_chatroom's Introduction

1.访问方式

本文使用内置的tomcat 访问地址web http://localhost:8080/chatroom/

websocket地址--->ws://127.0.0.1:8080/chatroom/ws MyWebSocketClient client = new MyWebSocketClient(new URI("ws://127.0.0.1:8080/chatroom/ws"), new Draft_6455(), headers, 10000); (注意new Draft_6455()是必不可少的)

2.客户端登录运行

浏览器用户aaa和www登录,F12获取到头域Cookie: JSESSIONID=9BED8BA56B6BE0E92777C743979F2B30和Cookie: JSESSIONID=9BED8BA56B6BE0E92777C743979F2B30 注意

MyWebSocketClient

        String userName="aaa";
        Map<String, String> headers = new HashMap<>();
        headers.put("Cookie", "JSESSIONID=6CD7248AD419C7DFDC696FA01C28A467");
MyWebSocketClient2
        String userName="www";
        Map<String, String> headers = new HashMap<>();
        headers.put("Cookie", "JSESSIONID=1345391D0C50435F6E0896F28759C769");

3.可以实现两个用户互相发消息

websocket_chatroom's People

Contributors

heheliu321 avatar

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.