• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SendToUser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.messaging.simp.annotation.SendToUser的典型用法代码示例。如果您正苦于以下问题:Java SendToUser类的具体用法?Java SendToUser怎么用?Java SendToUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SendToUser类属于org.springframework.messaging.simp.annotation包,在下文中一共展示了SendToUser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createGame

import org.springframework.messaging.simp.annotation.SendToUser; //导入依赖的package包/类
@ApiMethod(description = "Create a new lobby.")
@MessageMapping("/lobby/create")
@SendToUser("/queue/lobby/joined")
public Lobby createGame(@Validated CreateGameAction action, Principal principal) {
    checkThatUserIsNotInAGame(principal, "cannot create another game");

    Player gameOwner = playerRepository.find(principal.getName());
    Lobby lobby = lobbyRepository.create(action.getGameName(), gameOwner);

    logger.info("Game '{}' ({}) created by {} ({})", lobby.getName(), lobby.getId(), gameOwner.getDisplayName(),
            gameOwner.getUsername());

    // notify everyone that a new game exists
    template.convertAndSend("/topic/games", Collections.singletonList(lobby));
    return lobby;
}
 
开发者ID:luxons,项目名称:seven-wonders,代码行数:17,代码来源:GameBrowserController.java


示例2: handleError

import org.springframework.messaging.simp.annotation.SendToUser; //导入依赖的package包/类
@MessageExceptionHandler(Exception.class)
@SendToUser("${appverse.frontfacade.websocket.exceptionHandler.path:/queue/errors}")
public ResponseDataVO handleError(Exception exception) {
    ResponseDataVO data = new ResponseDataVO();
    ErrorVO error = new ErrorVO();

    Long code = 500L;
    if(exception instanceof AbstractException) {
        if (((AbstractException) exception).getCode() != null) {
            code = ((AbstractException) exception).getCode();
        }
    }
    error.setCode(code);
    error.setMessage(exception.getMessage());
    data.setErrorVO(error);
    return data;
}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:18,代码来源:WebSocketExceptionHandler.java


示例3: join

import org.springframework.messaging.simp.annotation.SendToUser; //导入依赖的package包/类
/**
 * direct message handler that receives a join message from a device. When a device joins, a session is attempted to
 * be found within a tolerated geo-proximity. if one is found, the device is added to it and returned, if not, a
 * new session is created.
 *
 * @param   j   a stringified JoinMessage sent from the device seeking to join a session
 * @return      stringified JoinResponse
 *
 * @see     JoinMessage
 * @see     JoinResponse
 */
@MessageMapping("/join")
@SendToUser("/queue/device")
public String join(JoinMessage j) {
    String joinType = j.getType().toString();
    switch(joinType){
        case "enter":
            break;
        case "exit":
            Session session = (Session) this.sessionService.get(j);
            String uuid = session.getUuid().toString();
            //Return join
            String joinResponse = gson.toJson(new JoinResponse(session.getApplicationId(), uuid, session.getDevices(), session.getRoom()), JoinResponse.class);
            if(logger.isDebugEnabled())
                logger.debug(String.format("JOIN RESPONSE: %s", joinResponse));
            return joinResponse;
        default:
            logger.error(String.format("Detected SyncType %s not supported", joinType));
    }
    return null;
}
 
开发者ID:wieden-kennedy,项目名称:composite-framework,代码行数:32,代码来源:CompositeController.java


示例4: pair

import org.springframework.messaging.simp.annotation.SendToUser; //导入依赖的package包/类
/**
 * Direct message handler that receives pair message from a device. When device joins, session is found or a new
 * pair session is created.
 *
 * @param p     Stringified PairMessage sent from device seeking to pair up with another device
 * @return      Stringified PairResponse
 *
 * @see         PairResponse
 * @see         PairMessage
 */
@MessageMapping("/pair")
@SendToUser("/queue/device")
public String pair(PairMessage p){
    String pairType = p.getType().toString();
    switch(pairType){
        case "enter":
            break;
        case "exit":
            Session session = this.sessionService.pair(p);
            String uuid = session.getUuid().toString();
            // Return pair
            String pairResponse = gson.toJson(new PairResponse(session.getApplicationId(), uuid,session.getDevices()),PairResponse.class);
            if(logger.isDebugEnabled()){
                logger.debug(String.format("PAIR RESPONSE: %s", pairResponse));
            }
            return pairResponse;
        default:
            logger.error(String.format("Detected SyncType %s not supported", pairType));
    }
    return null;
}
 
开发者ID:wieden-kennedy,项目名称:composite-framework,代码行数:32,代码来源:CompositeController.java


示例5: supportsReturnType

import org.springframework.messaging.simp.annotation.SendToUser; //导入依赖的package包/类
@Override
public boolean supportsReturnType(MethodParameter returnType) {
	if (returnType.getMethodAnnotation(SendTo.class) != null ||
			returnType.getMethodAnnotation(SendToUser.class) != null) {
		return true;
	}
	return (!this.annotationRequired);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:SendToMethodReturnValueHandler.java


示例6: name

import org.springframework.messaging.simp.annotation.SendToUser; //导入依赖的package包/类
@ApiMethod(description = "Creates/updates the player's name (for the user's session)")
@MessageMapping("/chooseName")
@SendToUser("/queue/nameChoice")
public Player chooseName(@Validated ChooseNameAction action, Principal principal) {
    String username = principal.getName();
    Player player = playerRepository.createOrUpdate(username, action.getPlayerName());

    logger.info("Player '{}' chose the name '{}'", username, player.getDisplayName());
    return player;
}
 
开发者ID:luxons,项目名称:seven-wonders,代码行数:11,代码来源:HomeController.java


示例7: joinGame

import org.springframework.messaging.simp.annotation.SendToUser; //导入依赖的package包/类
@ApiMethod(description = "Join an existing lobby.")
@MessageMapping("/lobby/join")
@SendToUser("/queue/lobby/joined")
public Lobby joinGame(@Validated JoinGameAction action, Principal principal) {
    checkThatUserIsNotInAGame(principal, "cannot join another game");

    Lobby lobby = lobbyRepository.find(action.getGameId());
    Player newPlayer = playerRepository.find(principal.getName());
    lobby.addPlayer(newPlayer);

    logger.info("Player '{}' ({}) joined game {}", newPlayer.getDisplayName(), newPlayer.getUsername(),
            lobby.getName());
    lobbyController.sendLobbyUpdateToPlayers(lobby);
    return lobby;
}
 
开发者ID:luxons,项目名称:seven-wonders,代码行数:16,代码来源:GameBrowserController.java


示例8: handleUserInputError

import org.springframework.messaging.simp.annotation.SendToUser; //导入依赖的package包/类
@MessageExceptionHandler
@SendToUser("/queue/errors")
public UIError handleUserInputError(UserInputException exception) {
    logger.error("Incorrect user input: " + exception.getMessage());
    String messageKey = exception.getMessageResourceKey();
    String message = messageSource.getMessage(messageKey, exception.getParams(), messageKey, Locale.US);
    return new UIError(messageKey, message, ErrorType.USER_INPUT);
}
 
开发者ID:luxons,项目名称:seven-wonders,代码行数:9,代码来源:ExceptionHandler.java


示例9: handleValidationError

import org.springframework.messaging.simp.annotation.SendToUser; //导入依赖的package包/类
@MessageExceptionHandler
@SendToUser("/queue/errors")
public UIError handleValidationError(MethodArgumentNotValidException exception) {
    logger.error("Invalid input", exception);
    UIError uiError = new UIError(ERROR_CODE_VALIDATION, ERROR_MSG_VALIDATION, ErrorType.VALIDATION);

    BindingResult result = exception.getBindingResult();
    if (result != null) {
        List<ObjectError> errors = result.getAllErrors();
        uiError.addDetails(errors);
    }
    return uiError;
}
 
开发者ID:luxons,项目名称:seven-wonders,代码行数:14,代码来源:ExceptionHandler.java


示例10: handleException

import org.springframework.messaging.simp.annotation.SendToUser; //导入依赖的package包/类
/**
 * direct-message handler to send messaging errors to a device in session
 *
 * @param   exception   the exception that was thrown by the messaging error
 * @return              String, the message sent back to the device containing the error
 */
@MessageExceptionHandler
@SendToUser("/queue/errors")
public String handleException(Throwable exception) {
    logger.error("Handling exception: ", exception);
    return exception.getMessage();
}
 
开发者ID:wieden-kennedy,项目名称:composite-framework,代码行数:13,代码来源:CompositeController.java


示例11: sendToUser

import org.springframework.messaging.simp.annotation.SendToUser; //导入依赖的package包/类
@ApiOperation("WebSocket单播:客户端接收一对一消息的主题应该是“/user/” + 用户Id + “/message” ")
@SendToUser("/message")
public SocketMessage sendToUser(SocketMessage message){
    return message;
}
 
开发者ID:ChinaLHR,项目名称:JavaQuarkBBS,代码行数:6,代码来源:WebSocketController.java


示例12: authenticatedUser

import org.springframework.messaging.simp.annotation.SendToUser; //导入依赖的package包/类
@MessageMapping("/ws-auth")
@SendToUser(value = "/queue/ws-auth", broadcast = false)
public Person authenticatedUser(Principal principal) {
    return new Person(new PersonalData(principal.getName(), principal.getName()));
}
 
开发者ID:borysfan,项目名称:websocket-poc,代码行数:6,代码来源:PersonWebSocketController.java


示例13: supportsReturnType

import org.springframework.messaging.simp.annotation.SendToUser; //导入依赖的package包/类
@Override
public boolean supportsReturnType(MethodParameter returnType) {
	return (returnType.getMethodAnnotation(SubscribeMapping.class) != null &&
			returnType.getMethodAnnotation(SendTo.class) == null &&
			returnType.getMethodAnnotation(SendToUser.class) == null);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:7,代码来源:SubscriptionMethodReturnValueHandler.java


示例14: handleAndSendToUserDefaultDestination

import org.springframework.messaging.simp.annotation.SendToUser; //导入依赖的package包/类
@SendToUser
public String handleAndSendToUserDefaultDestination() {
	return PAYLOAD;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:SendToMethodReturnValueHandlerTests.java


示例15: handleAndSendToUserDefaultDestinationSingleSession

import org.springframework.messaging.simp.annotation.SendToUser; //导入依赖的package包/类
@SendToUser(broadcast = false)
public String handleAndSendToUserDefaultDestinationSingleSession() {
	return PAYLOAD;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:SendToMethodReturnValueHandlerTests.java


示例16: handleAndSendToUser

import org.springframework.messaging.simp.annotation.SendToUser; //导入依赖的package包/类
@SendToUser({"/dest1", "/dest2"})
public String handleAndSendToUser() {
	return PAYLOAD;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:SendToMethodReturnValueHandlerTests.java


示例17: handleAndSendToUserSingleSession

import org.springframework.messaging.simp.annotation.SendToUser; //导入依赖的package包/类
@SendToUser(destinations = { "/dest1", "/dest2" }, broadcast = false)
public String handleAndSendToUserSingleSession() {
	return PAYLOAD;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:SendToMethodReturnValueHandlerTests.java


示例18: handleException

import org.springframework.messaging.simp.annotation.SendToUser; //导入依赖的package包/类
@MessageExceptionHandler
@SendToUser("/queue/error")
public String handleException(IllegalArgumentException ex) {
	return "Got error: " + ex.getMessage();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:6,代码来源:StompWebSocketIntegrationTests.java


示例19: handleConversionError

import org.springframework.messaging.simp.annotation.SendToUser; //导入依赖的package包/类
@MessageExceptionHandler
@SendToUser("/queue/errors")
public UIError handleConversionError(MessageConversionException exception) {
    logger.error("Error interpreting the message", exception);
    return new UIError(ERROR_CODE_CONVERSION, ERROR_MSG_CONVERSION, ErrorType.VALIDATION);
}
 
开发者ID:luxons,项目名称:seven-wonders,代码行数:7,代码来源:ExceptionHandler.java


示例20: handleApiError

import org.springframework.messaging.simp.annotation.SendToUser; //导入依赖的package包/类
@MessageExceptionHandler
@SendToUser("/queue/errors")
public UIError handleApiError(ApiMisuseException exception) {
    logger.error("Invalid API input", exception);
    return new UIError(exception.getClass().getSimpleName(), exception.getMessage(), ErrorType.CLIENT);
}
 
开发者ID:luxons,项目名称:seven-wonders,代码行数:7,代码来源:ExceptionHandler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ClientResponseFailure类代码示例发布时间:2022-05-22
下一篇:
Java ConstraintSatisfactionAction类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap