当前位置: 首页>>代码示例>>Java>>正文


Java TextMessage.getPayload方法代码示例

本文整理汇总了Java中org.springframework.web.socket.TextMessage.getPayload方法的典型用法代码示例。如果您正苦于以下问题:Java TextMessage.getPayload方法的具体用法?Java TextMessage.getPayload怎么用?Java TextMessage.getPayload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.web.socket.TextMessage的用法示例。


在下文中一共展示了TextMessage.getPayload方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleTextMessage

import org.springframework.web.socket.TextMessage; //导入方法依赖的package包/类
@Override
public void handleTextMessage(WebSocketSession session, TextMessage message) throws IOException {
	String country = message.getPayload();
	String reply="No data available";
	if(country.equals("India"))
	{
		reply="DELHI";
	}
	else if(country.equals("USA"))
	{
		reply="Washington,D.C";
	}
	System.out.println("handling message");
	
	for(WebSocketSession webSsession:sessions)
	{
		session.sendMessage(new TextMessage(reply));	
	}
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-5.0,代码行数:20,代码来源:MyMessageHandler.java

示例2: handleMessage

import org.springframework.web.socket.TextMessage; //导入方法依赖的package包/类
public void handleMessage(TextMessage message, WebSocketSession wsSession) throws Exception {
	String payload = message.getPayload();
	if (StringUtils.isEmpty(payload)) {
		return;
	}
	String[] messages;
	try {
		messages = getSockJsServiceConfig().getMessageCodec().decode(payload);
	}
	catch (Throwable ex) {
		logger.error("Broken data received. Terminating WebSocket connection abruptly", ex);
		tryCloseWithSockJsTransportError(ex, CloseStatus.BAD_DATA);
		return;
	}
	delegateMessages(messages);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:WebSocketServerSockJsSession.java

示例3: handleTextMessage

import org.springframework.web.socket.TextMessage; //导入方法依赖的package包/类
@Override
protected void handleTextMessage(WebSocketSession session, TextMessage message)
		throws Exception {
	String payload = message.getPayload();
	if ("west".equals(payload)) {
		this.snake.setDirection(Direction.WEST);
	}
	else if ("north".equals(payload)) {
		this.snake.setDirection(Direction.NORTH);
	}
	else if ("east".equals(payload)) {
		this.snake.setDirection(Direction.EAST);
	}
	else if ("south".equals(payload)) {
		this.snake.setDirection(Direction.SOUTH);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:SnakeWebSocketHandler.java

示例4: handleTextMessage

import org.springframework.web.socket.TextMessage; //导入方法依赖的package包/类
@Override
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
    String logItem = message.getPayload();

    if (logItem.length() < MIN_LENGTH_LOG) {
        return;
    }

    // parse log item "category#index#zone#agent#cmdId#content" and send to event "zone:agent"
    int categoryIndex = logItem.indexOf('#', 0);
    String category = logItem.substring(0, categoryIndex);

    int numberIndex = logItem.indexOf('#', categoryIndex + 1);
    String number = logItem.substring(categoryIndex + 1, numberIndex);

    int zoneIndex = logItem.indexOf('#', numberIndex + 1);
    String zone = logItem.substring(numberIndex + 1, zoneIndex);

    int agentIndex = logItem.indexOf('#', zoneIndex + 1);
    String agent = logItem.substring(zoneIndex + 1, agentIndex);

    int cmdIdIndex = logItem.indexOf('#', agentIndex + 1);
    String cmdId = logItem.substring(agentIndex + 1, cmdIdIndex);

    String content = logItem.substring(cmdIdIndex + 1);

    if (category.equals(CmdType.RUN_SHELL.toString())) {
        sendCmdLog(cmdId, content, number);
        return;
    }

    if (category.equals(CmdType.SYSTEM_INFO.toString())) {
        sendAgentSysInfo(content);
    }
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:36,代码来源:CmdLoggingConsumer.java

示例5: handleTextMessage

import org.springframework.web.socket.TextMessage; //导入方法依赖的package包/类
private void handleTextMessage(WebSocketSession session, TextMessage webSocketMessage) throws Exception {
    String incomingString = webSocketMessage.getPayload();
    String chargeBoxId = getChargeBoxId(session);

    log.info("[chargeBoxId={}, sessionId={}] Received message: {}", chargeBoxId, session.getId(), incomingString);

    CommunicationContext context = new CommunicationContext();
    context.setSession(session);
    context.setChargeBoxId(chargeBoxId);
    context.setIncomingString(incomingString);

    pipeline.process(context);
}
 
开发者ID:RWTH-i5-IDSG,项目名称:steve-plugsurfing,代码行数:14,代码来源:AbstractWebSocketEndpoint.java

示例6: handleTextMessage

import org.springframework.web.socket.TextMessage; //导入方法依赖的package包/类
@Override
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
	String json = message.getPayload();
	T t = JSON.parseObject(json, clazz);
	onMessage(session, t);
}
 
开发者ID:yanfanvip,项目名称:RedisClusterManager,代码行数:7,代码来源:ObjectWebSocketHandler.java

示例7: handleTextMessage

import org.springframework.web.socket.TextMessage; //导入方法依赖的package包/类
@Override
protected void handleTextMessage(final WebSocketSession session, final TextMessage message) throws Exception {
    RxClient rxClient = rxClientMap.get(session.getId());
    if (rxClient == null) {
        session.close();
        return;
    }
    final String command = message.getPayload();
    if (command.equalsIgnoreCase("sync")) {
        sync(session);
    } else {
        String auth = authMap.get(session.getId());

        observableMap.get(session.getId())
                .subscribe(connection -> {
                    if (auth != null) {
                        connection.writeAndFlush("auth " + auth + "\r\n" + command + "\r\n");
                    } else {
                        connection.writeAndFlush(command + "\r\n");
                    }
                    connection.getInput()
                            .distinct()
                            .subscribe(response -> {
                                String requestMessage;
                                if (response instanceof DefaultLastBulkStringRedisContent) {
                                    DefaultLastBulkStringRedisContent content = (DefaultLastBulkStringRedisContent) response;
                                    byte[] bytes = new byte[content.content().readableBytes()];
                                    content.content().readBytes(bytes);
                                    requestMessage = new String(bytes);
                                } else if (response instanceof IntegerRedisMessage) {
                                    requestMessage = String.valueOf(((IntegerRedisMessage) response).value());
                                } else if (response instanceof ErrorRedisMessage) {
                                    requestMessage = ((ErrorRedisMessage) response).content();
                                } else if (response instanceof FullBulkStringRedisMessage) {
                                    requestMessage = "nil";
                                } else if (response instanceof SimpleStringRedisMessage) {
                                    requestMessage = ((SimpleStringRedisMessage) response).content();
                                } else if (response instanceof BulkStringHeaderRedisMessage || response instanceof DefaultBulkStringRedisContent || response instanceof ArrayHeaderRedisMessage) {
                                    return;
                                } else {
                                    requestMessage = response.toString();
                                }

                                try {
                                    session.sendMessage(new TextMessage(requestMessage));
                                } catch (IOException e) {
                                    logger.warn(e.getMessage());
                                }
                            });
                });
    }
}
 
开发者ID:wu191287278,项目名称:sc-generator,代码行数:53,代码来源:RedisTextWebSocketHandler.java

示例8: executeSendRequestInternal

import org.springframework.web.socket.TextMessage; //导入方法依赖的package包/类
@Override
public ResponseEntity<String> executeSendRequestInternal(URI url, HttpHeaders headers, TextMessage message) {
	RequestCallback requestCallback = new XhrRequestCallback(headers, message.getPayload());
	return this.restTemplate.execute(url, HttpMethod.POST, requestCallback, textResponseExtractor);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:6,代码来源:RestTemplateXhrTransport.java

示例9: handleTextMessage

import org.springframework.web.socket.TextMessage; //导入方法依赖的package包/类
@Override
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
	// TODO Auto-generated method stub
	super.handleTextMessage(session, message);
	
	message.getPayload();
	
	
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:10,代码来源:TestRunHandler.java


注:本文中的org.springframework.web.socket.TextMessage.getPayload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。