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 […]

Publish and subscribe model implemented based on fixed-length blocking message queue [c++]

#include <iostream> #include <vector> #include <queue> #include <thread> #include <mutex> #include <condition_variable> #include <functional> #include <cstring> #include <chrono> // Custom message structure template <typename CallbackType> struct CustomMessage { CallbackType callback; void* data; size_t length; CustomMessage(CallbackType callback, void* data, size_t length) : callback(callback), data(data), length(length) {} CustomMessage() = default; // Add default constructor }; // message […]

Subscriber of Fast DDS

Directory Subscriber SubscriberQos SubscriberListener Create Subscriber DataReader SampleInfo Read data Get data through callback Processed by starting a waiting thread Subscriber plays the role of a container, and there can be many DataReaders in it. They use the same SubscriberQos configuration of Subscriber. Subscriber can carry DataReader objects of different Topics and data types. Subscriber […]

Use the Redis publish and subscribe function to implement dynamic registration monitoring and asynchronous retrieval of results

Introduction and objectives Publish/subscribe is very commonly used in our system development. Redis also provides this function, but it implements relatively basic functions. Redis cannot achieve these functions of reliable message publishing, subscription and message accumulation. But we can still use it to handle many business scenarios, such as: Our system uses services to call […]

Subscribe to topics from rosbag–take images as an example

This article is a supplement to the CSDN blog that uses the subscription function of ROS topics to extract information from bag files_rosbag extracts multiple topic information. ROS creates workspace code with one click conda deactivate # if necessary # Check path echo “the current space is ” pwd #Initialize workspace mkdir -p ./rosbag-ext/src cd […]

Use the Redis publish-subscribe model to implement session sharing

In fact, it is not to realize session sharing, but to use redis publish and subscribe, so that all cluster servers can send messages to their own sessions. For example, if userId is on the 35th server and there are 100 servers, then the first server receives the message and needs to notify userId. Instead […]

Handwritten redux connect method, using subscribe to get the latest data

1. Public method files 1. connect file import React, { useState } from “react”; import MyContext from “./MyContext”; import _ from “lodash”; // Simulate the connect high-order function of react-redux const connect = (mapStateToProps, mapDispatchToProps) => { return (Component) => props => wrapper(Component, {mapStateToProps, mapDispatchToProps, …props}); }; const wrapper = (Comp, props) => { const […]

SpringBoot+Redis publish-subscribe mode encapsulates custom annotations for logs between microservices

Scene: In projects, system operation records are usually saved as logs in order to record user operation behaviors and analyze system problems when system failures occur. In order to maintain the low intrusion of code and the standardization of log data between microservices, You can use custom log annotations to achieve the above purpose, and […]

Use the SpringBoot project to connect mqtt to implement message processing between publishers and subscribers

Build MQTT server and client (Windows): https://blog.csdn.net/weixin_42113716/article/details/133821761?csdn_share_tail={“type”:”blog”,”rType”:”article”,” rId”:”133821761″,”source”:”weixin_42113716″} Project structure: 1. The first step is to add the pom package: <!–mqtt–> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-integration</artifactId> </dependency> <dependency> <groupId>org.springframework.integration</groupId> <artifactId>spring-integration-stream</artifactId> </dependency> <dependency> <groupId>org.springframework.integration</groupId> <artifactId>spring-integration-mqtt</artifactId> </dependency> 2. In the second step, add the yml file as follows: server: port: 9999 spring: mqtt: username: admin # Username password: admin_public […]