# websocketdemo **Repository Path**: SeltD/websocketdemo ## Basic Information - **Project Name**: websocketdemo - **Description**: websocket demo - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-01-05 - **Last Updated**: 2022-02-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # websocket demo ### 原文参考:https://blog.csdn.net/moshowgame/article/details/80275084 ##### 什么是websocket websocket是一种基于tcp的一种新的网络协议。它实现了浏览器与服务器全双工(full-duplex)通信,允许服务器主动向客户端发送消息。 ![At](images/20180510225115144.png) 弥补了http协议的缺陷:通信只能又客服端发起,做不到服务器主动向客户端推送消息---通常使用页面轮询向服务器发送请求获取动态结果,效率低下且浪费资源 ![at](images/20180510223926952.png) ### websocket是原型模式,@ServerEndpoint每次建立双向通信的时候都会创建一个实例,区别spring的单例模式。@Componet默认是单例模式,可以被改变。 ### 可以使用netty实现更高效的websocket通信