spring boot+vue实现H5聊天室客服功能
spring boot+vue实现H5聊天室客服功能
h5效果图

vue效果图

功能实现
spring boot+webSocket实现- 官方地址 https://docs.spring.io/spring-framework/docs/5.0.8.RELEASE/spring-framework-reference/web.html#websocket
maven 配置文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.2.0.RELEASE</version>
</parent>
<groupId>org.example</groupId>
<artifactId>webChat</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.78</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
webSocket配置
package com.example.webchat.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean;
/**
* @author Mr.Fang
* @title: WebSocketConfig
* @Description: web socket 配置
* @date 2021/11/14 13:12
*/
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(myHandler(), "myHandler/") // 访问路径
.addInterceptors(new WebSocketHandlerInterceptor()) // 配置拦截器
.setAllowedOrigins("*"); // 跨域
}
@Bean
public ServletServerContainerFactoryBean createWebSocketContainer() {
ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
container.setMaxTextMessageBufferSize(8192); // 例如消息缓冲区大小、空闲超时等
container.setMaxBinaryMessageBufferSize(8192);
return container;
}
@Bean
public WebSocketHandler myHandler() {
return new MyHandler();
}
}
消息处理类
package com.example.webchat.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.webchat.pojo.DataVo;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.handler.AbstractWebSocketHandler;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author Mr.Fang
* @title: MyHandler
* @Description: 消息处理类
* @date 2021/11/14 13:12
*/
public class MyHandler extends AbstractWebSocketHandler {
private static int onlineCount = 0;
// 线程安全
private static Map<String, WebSocketSession> userMap = new ConcurrentHashMap<>(); // 用户
private static Map<String, WebSocketSession> adminMap = new ConcurrentHashMap<>(); // 客服
/**
* @Description: 连接成功之后
* @param session
* @return void
* @Author Mr.Fang
* @date 2021/11/14 13:15
*/
@Override
public void afterConnectionEstablished(WebSocketSession session) throws IOException {
addOnlineCount(); // 当前用户加 1
System.out.println(session.getId());
Map<String, Object> map = session.getAttributes();
Object token = map.get("token");
Object admin = map.get("admin");
DataVo dataVo = new DataVo();
dataVo.setCode(9001).setMsg("连接成功");
if (Objects.nonNull(admin)) {
adminMap.put(session.getId(), session); // 添加客服
} else {
// 分配客服
userMap.put(session.getId(), session); // 添加当前用户
distribution(dataVo);
}
dataVo.setId(session.getId());
System.out.println("用户连接成功:" + admin);
System.out.println("用户连接成功:" + token);
System.out.println("在线用户:" + getOnlineCount());
this.sendMsg(session, JSONObject.toJSONString(dataVo));
}
/**
* @param vo
* @return void
* @Description: 分配客服
* @Author Mr.Fang
* @date 2021/11/14 13:13
*/
private void distribution(DataVo vo) {
if (adminMap.size() != 0) {
Random random = new Random();
int x = random.nextInt(adminMap.size());
Set<String> values = adminMap.keySet();
int j = 0;
for (String str : values) {
if (j == x) {
vo.setRecId(str);
System.out.println("分配ID:" + str);
break;
}
j++;
}
}
}
/**
* @param session
* @param message
* @return void
* @Description: 收发消息
* @Author Mr.Fang
* @date 2021/11/14 13:13
*/
@Override
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
System.out.print("用户ID:" + session.getId());
String payload = message.getPayload();
System.out.println("接受到的数据:" + payload);
DataVo dataVo = JSON.toJavaObject(JSON.parseObject(payload), DataVo.class); // json 转对象
if (Objects.isNull(dataVo.getRecId()) || dataVo.getRecId().equals("")) { // 用户客服为空 分配客服
WebSocketSession socketSession = adminMap.get(session.getId());
if (Objects.isNull(socketSession)) {
this.distribution(dataVo);
}
}
if (dataVo.getCode() == 9002) {
if (Objects.nonNull(dataVo.getRecId())) { // user -> admin
WebSocketSession socketSession = adminMap.get(dataVo.getRecId());
dataVo.setSelfId(session.getId()).setRecId("");
this.sendMsg(socketSession, JSONObject.toJSONString(dataVo));
} else if (Objects.nonNull(dataVo.getSelfId())) { // admin ->user
WebSocketSession socketSession = userMap.get(dataVo.getSelfId());
dataVo.setRecId(session.getId()).setSelfId("");
this.sendMsg(socketSession, JSONObject.toJSONString(dataVo));
}
}
}
/**
* @param session
* @param msg
* @return void
* @Description: 发送消息
* @Author Mr.Fang
* @date 2021/11/14 13:14
*/
private void sendMsg(WebSocketSession session, String msg) throws IOException {
session.sendMessage(new TextMessage(msg));
}
/**
* @Description: 断开连接之后
* @param session
* @param status
* @return void
* @Author Mr.Fang
* @date 2021/11/14 13:14
*/
@Override
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) {
subOnlineCount(); // 当前用户加 1
adminMap.remove(session.getId());
userMap.remove(session.getId());
System.out.println("用户断开连接token:" + session.getId());
System.out.println("用户断开连接admin:" + session.getId());
System.out.println("在线用户:" + getOnlineCount());
}
public static synchronized int getOnlineCount() {
return onlineCount;
}
/**
* @Description: 在线用户 +1
* @return void
* @Author Mr.Fang
* @date 2021/11/14 13:16
*/
public static synchronized void addOnlineCount() {
MyHandler.onlineCount++;
}
/**
* @Description: 在线用户 -1
* @return void
* @Author Mr.Fang
* @date 2021/11/14 13:16
*/
public static synchronized void subOnlineCount() {
MyHandler.onlineCount--;
}
}
配置拦截器
package com.example.webchat.config;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import java.util.Objects;
/**
* @author Mr.Fang
* @title: WebSocketHandlerInterceptor
* @Description: 拦截器
* @date 2021/11/14 13:12
*/
public class WebSocketHandlerInterceptor extends HttpSessionHandshakeInterceptor {
/**
* @param request
* @param response
* @param wsHandler
* @param attributes
* @return boolean
* @Description: 握手之前
* @Author Mr.Fang
* @date 2021/11/14 13:18
*/
@Override
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception {
ServletServerHttpRequest servletRequest = (ServletServerHttpRequest) request;
HttpServletRequest re = servletRequest.getServletRequest();
Object token = re.getParameter("token");
Object admin = re.getParameter("admin");
if (Objects.isNull(token)) {
return false;
}
re.getSession().setAttribute("admin", admin);
re.getSession().setAttribute("token", token);
return super.beforeHandshake(request, response, wsHandler, attributes);
}
/**
* @param request
* @param response
* @param wsHandler
* @param ex
* @return boolean
* @Description: 握手之后
* @Author Mr.Fang
* @date 2021/11/14 13:18
*/
@Override
public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Exception ex) {
super.afterHandshake(request, response, wsHandler, ex);
}
}
h5服务端
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>服务端</title>
<style type="text/css">
#client {
margin: 0px auto;
width: 500px;
}
input {
width: 80%;
height: 40px;
border-radius: 5px;
border-color: #CCCCCC;
outline: #01FA01;
}
#button {
width: 84px;
height: 46px;
background-color: #5af3a5;
color: #fff;
font-size: 20px;
border-radius: 5px;
border: none;
box-shadow: 1px 1px 1px 1px #ccc;
cursor: pointer;
outline: #01FA01;
}
</style>
</head>
<body>
<div id="client">
<h1 style="text-align: center;">服务端发送消息</h1>
<div id="content" contenteditable=true
style="width: 500px;height: 500px;margin: 0px auto;border: 1px solid #000000;padding: 10px;border-radius: 10px;overflow: auto;">
</div>
<div style="padding: 5px;0px">
<input type="" value="" /> <button id="button" type="button">发送</button>
</div>
</div>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
$(() => {
var pushData = {
code: 9002,
msg: '',
selfId: '',
};
var time = null;
var path = 'ws://127.0.0.1:8009/myHandler/';
if (typeof(WebSocket) === "undefined") {
alert('不支持websocket')
return;
}
let id = Math.random(); // 随机数
// 实例化socket
var webSocket = new WebSocket(path + '?token=' + id+'&admin=1');
// 监听连接
webSocket.onopen = function(event) {
console.log(event);
interval();
};
// 监听消息
webSocket.onmessage = function(event) {
let data = JSON.parse(event.data);
pushData.selfId = data.selfId;
if (data.code == 9002) {
$('#content').append(
`<p style="text-align: right;"><span style="color:chocolate;">${data.msg}</span>:客户端</p>`
)
} else if (data.code == 9001) {
$('#content').append(`<p style="color:#a09b9b;text-align:center;" >连接成功</p>`);
}
console.log(event)
};
// 监听错误
webSocket.onerror = function(event) {
console.log(event)
$('#content').append(`<p style="color:#a09b9b;text-align:center;" >连接错误</p>`);
clearInterval();
};
// 发送消息
$('#button').click(() => {
let v = $('input').val();
if (v) {
pushData.code = 9002;
pushData.msg = v;
webSocket.send(JSON.stringify(pushData));
$('#content').append(
`<p>服务端:<span style="color: blueviolet;">${v}</span></p>`
)
$('input').val('');
}
})
function interval() {
time = setInterval(() => {
pushData.code = 9003;
pushData.msg = '心跳';
webSocket.send(JSON.stringify(pushData));
}, 5000);
}
function clearInterval() {
clearInterval(time);
}
})
</script>
</body>
</html>
客户端
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>客户端</title>
<style type="text/css">
#client {
margin: 0px auto;
width: 500px;
}
input {
width: 80%;
height: 40px;
border-radius: 5px;
border-color: #CCCCCC;
outline: #01FA01;
}
#button {
width: 84px;
height: 46px;
background-color: #5af3a5;
color: #fff;
font-size: 20px;
border-radius: 5px;
border: none;
box-shadow: 1px 1px 1px 1px #ccc;
cursor: pointer;
outline: #01FA01;
}
</style>
</head>
<body>
<div id="client">
<h1 style="text-align: center;">客户端发送消息</h1>
<div id="content" contenteditable=true
style="width: 500px;height: 500px;margin: 0px auto;border: 1px solid #000000;padding: 10px;border-radius: 10px;overflow: auto;">
</div>
<div style="padding: 5px;0px">
<input type="" value="" /> <button id="button" type="button">发送</button>
</div>
</div>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
$(() => {
var pushData = {
code: 9002,
msg: '',
recId: '',
};
var time = null;
var path = 'ws://127.0.0.1:8009/myHandler/';
if (typeof(WebSocket) === "undefined") {
alert('不支持websocket')
return;
}
let id = Math.random(); // 随机数
// 实例化socket
var webSocket = new WebSocket(path + '?token=' + id);
// 监听连接
webSocket.onopen = function(event) {
console.log(event);
interval();
};
// 监听消息
webSocket.onmessage = function(event) {
let data = JSON.parse(event.data);
if (data.code == 9002) {
$('#content').append(
`<p style="text-align: right;"><span style="color:chocolate;">${data.msg}</span>:服务端</p>`
)
} else if (data.code == 9001) {
$('#content').append(`<p style="color:#a09b9b;text-align:center;" >连接成功</p>`);
}
console.log(event)
};
// 监听错误
webSocket.onerror = function(event) {
console.log(event)
$('#content').append(`<p style="color:#a09b9b;text-align:center;" >连接错误</p>`);
clearInterval();
};
// 发送消息
$('#button').click(() => {
let v = $('input').val();
if (v) {
pushData.code = 9002;
pushData.msg = v;
webSocket.send(JSON.stringify(pushData));
$('#content').append(
`<p>客户端:<span style="color: blueviolet;">${v}</span></p>`
)
$('input').val('');
}
})
function interval() {
time = setInterval(() => {
pushData.code = 9003;
pushData.msg = '心跳';
webSocket.send(JSON.stringify(pushData));
}, 5000);
}
function clearInterval() {
clearInterval(time);
}
})
</script>
</body>
</html>
vue连接webSocket
<template>
<div class="chat">
<van-nav-bar fixed placeholder title="聊天内容" left-arrow />
<div id="content" ref="rightBody">
<div v-for="item in list" :key="item.id">
<div class="chat-model" v-if="item.isSelf">
<div>
<van-image width="45px" height="45px" fit="fill" round src="https://img01.yzcdn.cn/vant/cat.jpeg" />
</div>
<div class="chat-content chat-content-l">
{{item.content}}
</div>
</div>
<div class="chat-model" style="justify-content: flex-end" v-else>
<div class="chat-content chat-content-r">
{{item.content}}
</div>
<div>
<van-image width="45px" height="45px" fit="fill" round src="https://img01.yzcdn.cn/vant/cat.jpeg" />
</div>
</div>
</div>
</div>
<div id="bottom">
<input type="text" v-model="text" />
<van-button @click="onSend">发送</van-button>
</div>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
data() {
return {
path: "ws://192.168.31.156:8009/myHandler/", // socket 地址
socket: "",
text: '',
data: {
code: 9002,
msg: '',
recId: '',
},
list: [],
time: '', // 定时器
}
},
created() {
this.init()
},
methods: {
onSend() {
if (this.socket.readyState != 1) {
this.$toast('连接失败请重新进入');
return;
}
if (!this.text) {
this.$toast('请输入内容')
return;
}
var data = {
avator: 'https://img01.yzcdn.cn/vant/cat.jpeg',
content: this.text,
isSelf: false
}
this.list.push(data);
this.send()
this.text = '';
this.$refs.rightBody.scrollTop = this.$refs.rightBody.scrollHeight;
},
init: function() {
// 0 CONNECTING 连接尚未建立
// 1 OPEN WebSocket的链接已经建立
// 2 CLOSING 连接正在关闭
// 3 CLOSED 连接已经关闭或不可用
if (typeof(WebSocket) === "undefined") {
this.$toast('您的浏览器不支持socket')
} else {
let id = Math.random(); // 随机数
// 实例化socket
this.socket = new WebSocket(this.path + '?token=' + id);
// 监听socket连接
this.socket.onopen = this.open
// 监听socket错误信息
this.socket.onerror = this.error
// 监听socket消息
this.socket.onmessage = this.getMessage
// this.onHeartbeat(); // 心跳防止断开连接
}
},
open: function() {
this.$toast('连接成功')
},
error: function() {
this.$toast('连接失败')
},
getMessage: function(res) {
let t = JSON.parse(res.data);
var data = {
avator: 'https://img01.yzcdn.cn/vant/cat.jpeg',
content: t.msg,
isSelf: true
}
if (t.code == 9002) {
this.list.push(data);
}
this.data.recId = t.recId;
this.$refs.rightBody.scrollTop = this.$refs.rightBody.scrollHeight;
},
send: function() {
if (this.socket) {
this.data.code = 9002;
this.data.msg = this.text;
this.socket.send(JSON.stringify(this.data))
}
},
close: function() {
console.log("socket已经关闭")
},
onHeartbeat() {
var time = setInterval(() => {
this.data.code = 9003;
this.data.msg = '心跳';
this.socket.send(JSON.stringify(this.data))
}, 5000);
this.time = time;
}
},
destroyed() {
// 销毁监听
clearInterval(this.time);
this.socket.onclose = this.close
}
}
</script>
<style>
.chat {
height: 100vh;
background-color: #f1f1f3;
}
#content {
overflow: auto;
height: 100vh;
padding-bottom: 100px;
background-color: #f1f1f3;
}
#bottom {
position: fixed;
bottom: 0px;
width: 100%;
display: flex;
justify-content: space-evenly;
padding: 10px 0px;
background-color: #F1F1F3;
}
#bottom input {
background-color: white;
width: 72%;
height: 30px;
padding: 3px 5px;
vertical-align: sub;
border-style: none;
border-radius: 5px;
}
#bottom button {
height: 32px;
background-color: rgb(245, 158, 1);
border-radius: 5px;
color: #fff;
}
.chat-model {
display: flex;
flex-direction: row;
margin: 10px 10px;
margin-top: 30px;
align-items: center;
}
.chat-content {
position: relative;
max-width: 67%;
word-break: break-all;
word-wrap: break-word;
top: 18px;
padding: 10px;
border-radius: 5px;
background-color: white;
}
.chat-content-r {
right: 10px;
}
.chat-content-l {
left: 10px;
}
</style>
源码地址 https://gitee.com/bxmms/web-chat.git
spring boot+vue实现H5聊天室客服功能的更多相关文章
- 利用spring boot+vue做的一个博客项目
技术栈: 后端 Springboot druid Spring security 数据库 MySQL 前端 vue elementUI 项目演示: GitHub地址: 后端:https://githu ...
- spring boot + vue + element-ui全栈开发入门——开篇
最近经常看到很多java程序员朋友还在使用Spring 3.x,Spring MVC(struts),JSP.jQuery等这样传统技术.其实,我并不认为这些传统技术不好,而我想表达的是,技术的新旧程 ...
- spring boot + vue + element-ui全栈开发入门——基于Electron桌面应用开发
前言 Electron是由Github开发,用HTML,CSS和JavaScript来构建跨平台桌面应用程序的一个开源库. Electron通过将Chromium和Node.js合并到同一个运行时环 ...
- 前后端分离,我怎么就选择了 Spring Boot + Vue 技术栈?
前两天又有小伙伴私信松哥,问题还是职业规划,Java 技术栈路线这种,实际上对于这一类问题我经常不太敢回答,每个人的情况都不太一样,而小伙伴也很少详细介绍自己的情况,大都是一两句话就把问题抛出来了,啥 ...
- spring boot + vue + element-ui全栈开发入门
今天想弄弄element-ui 然后就在网上找了个例子 感觉还是可以用的 第一步是完成了 果断 拿过来 放到我这里这 下面直接是连接 点进去 就可以用啊 本想着不用vue 直接导入连接 ...
- 一个实际的案例介绍Spring Boot + Vue 前后端分离
介绍 最近在工作中做个新项目,后端选用Spring Boot,前端选用Vue技术.众所周知现在开发都是前后端分离,本文就将介绍一种前后端分离方式. 常规的开发方式 采用Spring Boot 开发项目 ...
- spring boot + vue + element-ui
spring boot + vue + element-ui 一.页面 1.布局 假设,我们要开发一个会员列表的页面. 首先,添加vue页面文件“src\pages\Member.vue” 参照文档h ...
- 喜大普奔,两个开源的 Spring Boot + Vue 前后端分离项目可以在线体验了
折腾了一周的域名备案昨天终于搞定了. 松哥第一时间想到赶紧把微人事和 V 部落部署上去,我知道很多小伙伴已经等不及了. 1. 也曾经上过线 其实这两个项目当时刚做好的时候,我就把它们部署到服务器上了, ...
- 部署spring boot + Vue遇到的坑(权限、刷新404、跨域、内存)
部署spring boot + Vue遇到的坑(权限.刷新404.跨域.内存) 项目背景是采用前后端分离,前端使用vue,后端使用springboot. 工具 工欲善其事必先利其器,我们先找一个操作L ...
随机推荐
- python读Excel方法(xlrd)
在我们做平常工作或自动化测试中都会遇到操作excel,Python处理exc相当顺手,如何通过python操作excel,当然python操作excel的库有很多,比如pandas,xlwt/xlrd ...
- MyBatis切换至MyBatis-plus踩坑Invalid bound statement (not found):
部分情况可以参考https://blog.csdn.net/wwrzyy/article/details/86034458 我的问题出现的根本原因就是没有扫描到mapper的xml文件 因为MyBat ...
- Mybatis-技术专区-Criteria的and和or进行联合条件查询
之前用Mybatis框架反向的实体,还有实体里面的Example,之前只是知道Example里面放的是条件查询的方法,可以一直不知道怎么用,到今天才开始知道怎么简单的用.在我们前台查询的时候会有许多的 ...
- OpenStack创建Win10实例
直接用Windows的iso文件创建实例是创建不出来的,需要先在kvm下创建qcow2格式的虚拟机,然后用已经创建好的虚拟机文件当做OpenStack的镜像来创建实例就好了. 首先第一点是需要有一台L ...
- 浏览器输入URL之后,HTTP请求返回的完整过程
1.输入url,按下回车时,先做一个redirect(重定向),因为浏览器可能记录本机的地址已经永久跳转成新的地址,所以一开始浏览器就先要判断下需不需要重定向,以及重定向到哪里:2.然后第二步就是看A ...
- 踩坑系列《二》NewProxyResultSet.isClosed()Z is abstract 报错踩坑
在运行测试类的时候莫名其妙的报了个 NewProxyResultSet.isClosed()Z is abstract 这个错误,之前出现过这个错误,以为是版本出现了问题 就将版本 0.9.1.2 改 ...
- NOIP 模拟 七十七
100+60+95+30; T4 一个变量打错挂了40.. T1 最大或 考虑从高到低枚举的二进制位,然后和的对应二进制位进行比较.如果两 者相同,那么不论怎么选择,,答案在这个位置上的值一定和在这个 ...
- python反序列化1(__reduce__)
part1:不求甚解的复现 对于服务端源码: 编写恶意序列化对象生成程序: 将生成的恶意序列化对象输入服务端user,使其执行系统命令.(上面那俩其实都行) part2:原理解释 b'xxx'是 ...
- 【UE4 C++】碰撞检测与事件绑定
概念 碰撞对象通道与预设 默认提供碰撞对象类型,如 WorldStatic.WorldDynamic等.允许用户自定义 默认提供碰撞预设,如 NoCollision.BloackAll.Overlap ...
- Java:动态代理小记
Java:动态代理小记 对 Java 中的 动态代理,做一个微不足道的小小小小记 概述 动态代理:当想要给实现了某个接口的类中的方法,加一些额外的处理.比如说加日志,加事务等.可以给这个类创建一个代理 ...