热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

javax.websocket.OnMessage类的使用及代码示例

本文整理了Java中javax.websocket.OnMessage类的一些代码示例,展示了OnMessage类的具体用法。这些代码示例主要

本文整理了Java中javax.websocket.OnMessage类的一些代码示例,展示了OnMessage类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OnMessage类的具体详情如下:
包路径:javax.websocket.OnMessage
类名称:OnMessage

OnMessage介绍

暂无

代码示例

代码示例来源:origin: scouter-project/scouter

@OnMessage
public String onWebSocketText(String message)
{
log.info("Echoing back text message [{}]",message);
// Using shortcut approach to sending messages.
// You could use a void method and use remote.sendText()
return message;
}
}

代码示例来源:origin: wso2/msf4j

@OnMessage
public void onTextMessage(@PathParam("name") String name, String text, Session session) throws IOException {
String msg = name + " : " + text;
LOGGER.info("Received Text : " + text + " from " + name + session.getId());
sendMessageToAll(msg);
}

代码示例来源:origin: crashub/crash

@OnMessage
public void incoming(String message, Session wsSession) {
String key = wsSession.getId();
log.fine("Received message " + message + " from session " + key);
current.set(wsSession);

代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.siddhi.editor.core

@OnMessage
public void onMessage(String text, Session session) {
try {
session.getBasicRemote().sendText("Welcome to Stream Processor Studio");
LOGGER.info("Received message : " + text);
} catch (IOException e) {
LOGGER.error(e.getMessage());
}
}

代码示例来源:origin: com.eduworks/ew.levr.core

@OnMessage
public void onMessage(Session session, String message)
map.put("wsId", new String[]{session.getId()});
Object result = LevrResolverServlet
.execute(log, false, mObject.getString("function"), new Context(), map, new HashMap(), true);
if (result instanceof String)
session.getBasicRemote().sendText(result.toString());
session.getBasicRemote().sendText(result.toString());

代码示例来源:origin: org.kie.server/kie-server-controller-websocket

@OnMessage
public void onMessage(final KieServerControllerDescriptorCommand command,
final Session session) {
LOGGER.debug("Message received on session: {}",
session.getId());
final KieServerControllerServiceResponse respOnse= commandService.executeCommand(command);
try {
session.getBasicRemote().sendObject(response);
} catch (IOException | EncodeException ex) {
LOGGER.error("Error trying to send Web Socket response: {}",
ex.getMessage(),
ex);
throw new RuntimeException(ex);
}
}

代码示例来源:origin: heibaiying/spring-samples-for-all

/**
* 处理消息
*/
@OnMessage
public void onMessage(Session session, String message, @PathParam("username") String username) throws UnsupportedEncodingException {
// 防止中文乱码
String msg = URLDecoder.decode(message, "utf-8");
// 简单模拟群发消息
Constant.nameAndSession.forEach((s, webSocketSession)
-> {
try {
webSocketSession.getBasicRemote().sendText(username + " : " + msg);
} catch (IOException e) {
e.printStackTrace();
}
});
}
}

代码示例来源:origin: mercyblitz/segmentfault-lessons

@OnMessage
public void onMessage(@PathParam("username") String username, Session session, String message) {
// sendText(session, "用户[" + username + "] : " + message);
sendTextAll("用户[" + username + "] : " + message);
}

代码示例来源:origin: eclipse/winery

@OnMessage
public void onMessage(String message) throws IOException {
RefinementWebSocketApiData data = this.mapper.readValue(message, RefinementWebSocketApiData.class);
try {
this.send(element);
session.close();
session = null;
} catch (JsonProcessingException e) {

代码示例来源:origin: org.eclipse.che.core/che-core-api-core

@OnMessage
public void onMessage(String messagePart, boolean last, Session session) {
try {
EnvironmentContext.getCurrent()
.setSubject((Subject) session.getUserProperties().get("che_subject"));
StringBuffer buffer = sessionMessagesBuffer.get(session);
buffer.append(messagePart);
if (last) {
try {
onMessage(buffer.toString(), session);
} finally {
buffer.setLength(0);
}
}
} finally {
EnvironmentContext.reset();
}
}

代码示例来源:origin: io.apicurio/apicurio-studio-be-hub-editing

@OnMessage
public void onMessage(Session session, JsonNode message) {
String designId = session.getPathParameters().get("designId");
ApiDesignEditingSession editingSession = editingSessionManager.getEditingSession(designId);
String msgType = message.get("type").asText();

代码示例来源:origin: codefollower/Tomcat-Research

indexPathParams.put(
Integer.valueOf(i), new PojoPathParam(types[i],
((PathParam) paramAnnotation).value()));
paramFound = true;
break;
maxMessageSize = m.getAnnotation(OnMessage.class).maxMessageSize();

代码示例来源:origin: org.eclipse.jetty.websocket/javax-websocket-server-impl

private int getMaxMessageSize(int defaultMaxMessageSize, OnMessageCallable... onMessages)
{
for (OnMessageCallable callable : onMessages)
{
if (callable == null)
{
continue;
}
OnMessage OnMsg= callable.getMethod().getAnnotation(OnMessage.class);
if (OnMsg== null)
{
continue;
}
if (onMsg.maxMessageSize() > 0)
{
return (int)onMsg.maxMessageSize();
}
}
return defaultMaxMessageSize;
}

代码示例来源:origin: wso2/msf4j

@OnMessage
public void onTextMessage(@PathParam("name") String name, String text, Session session) throws IOException {
String msg = name + " : " + text;
LOGGER.info("Received Text : " + text + " from " + name + session.getId());
sendMessageToAll(msg);
}

代码示例来源:origin: org.aktin/broker-server

@OnMessage
public void message(Session session, String message){
log.info("Session message: "+session.getId()+": "+message);
}

代码示例来源:origin: addthis/hydra

/**
* Simply echos client message unless it is "ping" in which case the return message will be "pong".
*/
@OnMessage
public void onWebSocketText(Session session, String message) {
try {
if ("ping".equals(message)) {
session.getBasicRemote().sendText("pong");
} else {
session.getBasicRemote().sendText(message);
}
} catch (IOException e) {
log.warn("Error responding to message: '{}': {}", message, e.toString());
}
}

代码示例来源:origin: org.apache.tomee/livereload-tomee

@OnMessage
public void onMessage(final String msg, final Session session) {
final Command command = mapper.readObject(msg, Command.class);
if (command.isHello()) {
try {
session.getBasicRemote().sendText(mapper.writeObjectAsString(HELLO));
} catch (final IOException e) {
throw new IllegalStateException(e);
}
this.watcher.addSession(session);
logger.info("Registered livereload session #" + session.getId());
} else if (command.isClientUpdate()) {
logger.info("Ignoring livereload client update message: " + msg);
} else if (command.isInfo()) {
if (!loggedInfo) {
logger.info("Livereload registration:\n - url:" + command.getUrl() + "\n - plugins: " + command.getPlugins());
loggedInfo = true;
}
} else {
logger.info("Unknown livereload message: " + msg);
}
}

代码示例来源:origin: battcn/spring-boot2-learning

@OnMessage
public void onMessage(@PathParam("username") String username, String message) {
log.info(message);
sendMessageAll("用户[" + username + "] : " + message);
}

代码示例来源:origin: Apicurio/apicurio-studio

@OnMessage
public void onMessage(Session session, JsonNode message) {
String designId = session.getPathParameters().get("designId");
ApiDesignEditingSession editingSession = editingSessionManager.getEditingSession(designId);
String msgType = message.get("type").asText();

代码示例来源:origin: org.apache.tomcat/tomcat-websocket

indexPathParams.put(
Integer.valueOf(i), new PojoPathParam(types[i],
((PathParam) paramAnnotation).value()));
paramFound = true;
break;
maxMessageSize = m.getAnnotation(OnMessage.class).maxMessageSize();

推荐阅读
author-avatar
曾军78930
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有