Vue uses websocket to implement real-time data push and publish, subscribe and reconnect single sign-on functions.

Requirements: Use websocket to implement publishing, subscribing, network disconnection and reconnection, and account squeezing after single sign-in without using plug-ins. 1. Single sign-on (only one of the same account is online at the same time, multiple user logins are prohibited) Implementation: After the user logs in, the token token is obtained and stored locally. It […]

Cross-domain: Use JSONP and WebSocket to achieve cross-domain access

Cross-domain basic knowledge points: Cross-domain knowledge points Four ways for iframe to achieve cross-domain: Four ways for iframe to achieve cross-domain Note: The virtual host used in this article is also configured in the iframe above. Table of Contents JSONP cross domain Introduction to JSONP Cross-domain experiments: WebSocket cross domain Introduction to websockets Cross-domain experiments […]

springBoot project+websocket+vue realizes two-way communication

Table of Contents 1. Understand the WebSocket protocol WebSocket features Real time communication: Two-way communication: Long connection: Cross-domain communication: 2. Back-end code implementation Introduce maven dependencies WebSocketConfig WebSocketConfig function: WebSocketConfig.java code MyWebSocket @annotation explanation MyWebSocket function: MyWebSocket.java code 3. Test whether the server is connected normally 1. Open the websocket test gadget 2. Enter the […]

Springboot integrates redis, mybatis-plus and websocket exception framework code encapsulation

In the process of software development, a well-encapsulated, concise and elegant Family Bucket framework can greatly improve the work efficiency of developers, while also reducing the complexity of the code and making it easier to maintain in the future. The source code involved in this article is at the end of the article, with a […]

Solve the problem that springboot integrates websocket, redis, openfeign, redisTemplate, and openfeign classes that cannot be injected

In some businesses, we need to use long connections. We can use http long connections or websocket. In the framework of springboot as the backend, the technologies that can be borrowed are (netty, websocket) The version is as follows Software Version number jdk 21 springboot 3.1.5 springcloud 2022.0.4 Scene recurrence pom file <?xml version=”1.0″ encoding=”UTF-8″?> […]

websocket authentication @ServerEndpoint method

import org.springframework.stereotype.Component; import javax.servlet.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @Component public class SimpleCORSFilter implements Filter {<!– –> @Override public void init(FilterConfig filterConfig) throws ServletException {<!– –> } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {<!– –> HttpServletRequest req= (HttpServletRequest) request; req.getSession().setAttribute(“ipAddr”,req.getRemoteHost()); HttpServletResponse res = (HttpServletResponse)response; res.setHeader(“Access-Control-Allow-Origin”, “*”); res.setHeader(“Access-Control-Allow-Methods”, “POST, […]

Save server resources and achieve two-way data transmission – in-depth analysis of the WebSocket protocol

Jiangcheng Cheerful Pea: Personal homepage Personal column :《VUE》《javaScript》 Personal website : “Jiangcheng Cheerful Pea” The ideal of life is for an ideal life! Table of Contents ? Column introduction Article introduction 1. What is WebSocket? 2. Characteristics full duplex binary frame Protocol name shake hands advantage 2. Application scenarios ?Write at the end ? Column […]

java network communication: Springboot integrates Websocket

Network communication What is webSocket? WebSocket principle Springboot integrates websocket process Three elements of network communication: IP address (ipv4, ipv6), port number (unique identification of the application), protocol (rules for connection and communication, commonly used: tcp, udp) Community-House-Road Socket is short for “socket” and is used to establish communication links between computers, allowing data to […]