如何使用Spring 4捕获WebSocket服务器中的连接事件? [英] how to capture connection event in my webSocket server with Spring 4?

查看:144
本文介绍了如何使用Spring 4捕获WebSocket服务器中的连接事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此 https之后,我与spring 4,STOMP和sock.js进行了简单的Web套接字通信. ://github.com/rstoyanchev/spring-websocket-portfolio 和这个 http://assets.spring.io/wp/WebSocketBlogPost.html

好吧,我想知道是否可能发生捕获连接事件,例如当新客户端连接到服务器或客户端断开连接时,在Spring 4.0.0中是否可能?

well, I want to know if is possible capture connection events like when a new client was connected to my server or when a client was disconnected, is that possible in Spring 4.0.0?

推荐答案

这可以通过连接握手拦截器(

This an be done with a connection handshake interceptor (HttpSessionHandshakeInterceptor), quoting the documentation:

自定义初始HTTP WebSocket握手的最简单方法 请求是通过HandshakeInterceptor进行的,该握手公开了"before"和 之后"的握手方法.

The easiest way to customize the initial HTTP WebSocket handshake request is through a HandshakeInterceptor, which exposes "before" and "after" the handshake methods.

这篇关于如何使用Spring 4捕获WebSocket服务器中的连接事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆