GithubHelp home page GithubHelp logo

p2pchat's Introduction

P2PChat(使用UDP打洞技术实现P2P聊天)

======

本机调试方法

1.启动P2pUdpServer 服务端

[main] INFO io.itit.p2p.P2pUdpServer - Server Start port:9999

2.启动P2pUdpClient 客户端1

[main] INFO io.itit.p2p.P2pUdpClient - Client Start
[Thread-0] INFO io.itit.p2p.P2pUdpClient - onReceieveMessage data:{"cmd":"LOGIN","requestId":1,"rsp":"1"} from /127.0.0.1:9999
[Thread-0] INFO io.itit.p2p.P2pUdpClient - onReceieveMessage data:{"cmd":"LIST","requestId":2,"rsp":"{\"127.0.0.1:57561\":\"1\"}"} from /127.0.0.1:9999

3.启动P2pUdpClient 客户端2

[main] INFO io.itit.p2p.P2pUdpClient - Client Start
[Thread-0] INFO io.itit.p2p.P2pUdpClient - onReceieveMessage data:{"cmd":"LOGIN","requestId":1,"rsp":"2"} from /127.0.0.1:9999
[Thread-0] INFO io.itit.p2p.P2pUdpClient - onReceieveMessage data:{"cmd":"LIST","requestId":2,"rsp":"{\"127.0.0.1:57561\":\"1\",\"127.0.0.1:57562\":\"2\"}"} from /127.0.0.1:9999
[Thread-0] INFO io.itit.p2p.P2pUdpClient - onReceieveMessage data:{"cmd":"P2PCHAT","requestId":3} from /127.0.0.1:57561

4.客户端2收到P2PCHAT包后,就可以关闭服务端,两个客户端每隔5秒进行通信

[Thread-0] INFO io.itit.p2p.P2pUdpClient - onReceieveMessage data:{"cmd":"P2PCHAT","requestId":3} from /127.0.0.1:57561
[Thread-0] INFO io.itit.p2p.P2pUdpClient - onReceieveMessage data:{"cmd":"P2PCHAT","requestId":3} from /127.0.0.1:57561
[Thread-0] INFO io.itit.p2p.P2pUdpClient - onReceieveMessage data:{"cmd":"P2PCHAT","requestId":3} from /127.0.0.1:57561
[Thread-0] INFO io.itit.p2p.P2pUdpClient - onReceieveMessage data:{"cmd":"P2PCHAT","requestId":3} from /127.0.0.1:57561
[Thread-0] INFO io.itit.p2p.P2pUdpClient - onReceieveMessage data:{"cmd":"P2PCHAT","requestId":3} from /127.0.0.1:57561
[Thread-0] INFO io.itit.p2p.P2pUdpClient - onReceieveMessage data:{"cmd":"P2PCHAT","requestId":3} from /127.0.0.1:57561
[Thread-0] INFO io.itit.p2p.P2pUdpClient - onReceieveMessage data:{"cmd":"P2PCHAT","requestId":3} from /127.0.0.1:57561
[Thread-0] INFO io.itit.p2p.P2pUdpClient - onReceieveMessage data:{"cmd":"P2PCHAT","requestId":3} from /127.0.0.1:57561

p2pchat's People

Contributors

icecooly 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.