We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@BeforeHandshake public void handshake(Session session, HttpHeaders headers, @RequestParam String req, @RequestParam MultiValueMap reqMap, @PathVariable String arg, @PathVariable Map pathMap){ session.setSubprotocols("stomp");
// if (!"ok".equals(req)){ // System.out.println("Authentication failed!"); // session.close(); // } }
为什么req一直是null 完整代码 MyWebSocket package org.yeauty;
import io.netty.handler.codec.http.HttpHeaders; import io.netty.handler.timeout.IdleStateEvent; import org.springframework.util.MultiValueMap; import org.yeauty.annotation.*; import org.yeauty.pojo.Session;
import java.io.IOException; import java.util.Map;
/***
@author hjt
注解描述@serverendpoint
在Spring配置中声明ServerEndpointExporter,
它将扫描带有ServerEndpoint注释的WebSocket端点。
使用ServerEndpoint标注的bean将被注册为WebSocket端点。
所有配置都在这个注释中(例如@serverendpoint("/ws")) */ //@serverendpoint(path = "/ws/{arg}") @serverendpoint(host = "${ws.host}",port = "${ws.port}",path = "/test") public class MyWebSocket {
}
The text was updated successfully, but these errors were encountered:
这个是demo里面的代码?
Sorry, something went wrong.
是的
No branches or pull requests
// if (!"ok".equals(req)){
// System.out.println("Authentication failed!");
// session.close();
// }
}
为什么req一直是null
完整代码 MyWebSocket
package org.yeauty;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.timeout.IdleStateEvent;
import org.springframework.util.MultiValueMap;
import org.yeauty.annotation.*;
import org.yeauty.pojo.Session;
import java.io.IOException;
import java.util.Map;
/***
@author hjt
注解描述@serverendpoint
在Spring配置中声明ServerEndpointExporter,
它将扫描带有ServerEndpoint注释的WebSocket端点。
使用ServerEndpoint标注的bean将被注册为WebSocket端点。
所有配置都在这个注释中(例如@serverendpoint("/ws"))
*/
//@serverendpoint(path = "/ws/{arg}")
@serverendpoint(host = "${ws.host}",port = "${ws.port}",path = "/test")
public class MyWebSocket {
/***
*/
@BeforeHandshake
public void handshake(Session session, HttpHeaders headers, @RequestParam String req, @RequestParam MultiValueMap reqMap, @PathVariable String arg, @PathVariable Map pathMap){
session.setSubprotocols("stomp");
// if (!"ok".equals(req)){
// System.out.println("Authentication failed!");
// session.close();
// }
}
/***
*/
@onopen
public void onOpen(Session session, HttpHeaders headers, @RequestParam String req, @RequestParam MultiValueMap reqMap, @PathVariable String arg, @PathVariable Map pathMap){
System.out.println("new connection");
System.out.println(req);
}
/***
*/
@onclose
public void onClose(Session session) throws IOException {
System.out.println("one connection closed");
}
/***
*/
@onerror
public void onError(Session session, Throwable throwable) {
throwable.printStackTrace();
}
/***
*/
@OnMessage
public void onMessage(Session session, String message) {
System.out.println(message);
session.sendText("Hello Netty!");
}
/***
*/
@onbinary
public void onBinary(Session session, byte[] bytes) {
for (byte b : bytes) {
System.out.println(b);
}
session.sendBinary(bytes);
}
/***
*/
@onevent
public void onEvent(Session session, Object evt) {
if (evt instanceof IdleStateEvent) {
IdleStateEvent idleStateEvent = (IdleStateEvent) evt;
switch (idleStateEvent.state()) {
case READER_IDLE:
System.out.println("read idle");
break;
case WRITER_IDLE:
System.out.println("write idle");
break;
case ALL_IDLE:
System.out.println("all idle");
break;
default:
break;
}
}
}
}
The text was updated successfully, but these errors were encountered: