本文整理汇总了Java中org.atmosphere.config.service.Message类的典型用法代码示例。如果您正苦于以下问题:Java Message类的具体用法?Java Message怎么用?Java Message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Message类属于org.atmosphere.config.service包,在下文中一共展示了Message类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCategoryMessage
import org.atmosphere.config.service.Message; //导入依赖的package包/类
@Message(encoders = {JacksonEncoder.class}, decoders = {CategoryDecoder.class})
public Category onCategoryMessage(Category message) throws IOException {
if (!resources.containsKey(message.getClient())) {
resources.put(message.getClient(), message.getUuid());
return new Category(message.getClient(), " subscribe to category " + categoryName, resources.keySet(), getCategories(factory.lookupAll()));
}
if (message.getMessage().contains("disconnecting")) {
resources.remove(message.getClient());
return new Category(message.getClient(), " disconnected from category " + categoryName, resources.keySet(), getCategories(factory.lookupAll()));
}
message.setUsers(resources.keySet());
logger.info("{} just send {}", message.getClient(), message.getMessage());
return new Category(message.getClient(), message.getMessage(), resources.keySet(), getCategories(factory.lookupAll()));
}
示例2: onMessage
import org.atmosphere.config.service.Message; //导入依赖的package包/类
@Message(decoders = {ActivityDTOJacksonDecoder.class})
public void onMessage(AtmosphereResource atmosphereResource, ActivityDTO activityDTO) throws IOException {
if (activityDTO.getUserLogin() != null){
AtmosphereRequest request = atmosphereResource.getRequest();
activityDTO.setUuid(atmosphereResource.uuid());
activityDTO.setIpAddress(request.getRemoteAddr());
activityDTO.setTime(dateTimeFormatter.print(Calendar.getInstance().getTimeInMillis()));
String json = jsonMapper.writeValueAsString(activityDTO);
log.debug("Sending user tracking data {}", json);
b.broadcast(json);
}
}
示例3: onMessage
import org.atmosphere.config.service.Message; //导入依赖的package包/类
@Message(decoders = {ActivityDTOJacksonDecoder.class})
public void onMessage(AtmosphereResource atmosphereResource, ActivityDTO activityDTO) throws IOException {
AtmosphereRequest request = atmosphereResource.getRequest();
activityDTO.setUuid(atmosphereResource.uuid());
activityDTO.setIpAddress(request.getRemoteAddr());
activityDTO.setTime(dateTimeFormatter.print(Calendar.getInstance().getTimeInMillis()));
String json = jsonMapper.writeValueAsString(activityDTO);
log.debug("Sending user tracking data {}", json);
b.broadcast(json);
}
示例4: onMessage
import org.atmosphere.config.service.Message; //导入依赖的package包/类
@Message(decoders = {ActivityDTOJacksonDecoder.class})
public void onMessage(AtmosphereResource atmosphereResource, ActivityDTO activityDTO) throws IOException {
AtmosphereRequest request = atmosphereResource.getRequest();
activityDTO.setSessionId(request.getSession().getId());
activityDTO.setIpAddress(request.getRemoteAddr());
activityDTO.setTime(dateTimeFormatter.print(Calendar.getInstance().getTimeInMillis()));
String json = jsonMapper.writeValueAsString(activityDTO);
log.debug("Sending user tracking data {}", json);
for (AtmosphereResource trackerResource : b.getAtmosphereResources()) {
trackerResource.getResponse().write(json);
}
}
示例5: onMessage
import org.atmosphere.config.service.Message; //导入依赖的package包/类
@Message(encoders = {GsonEncoder.class}, decoders = {GsonDecoder.class})
public Data onMessage(Data data) throws IOException {
data.setTime(new Date().getTime());
logger.info("{} just send {}", data.getAuthor(), data.getMessage());
return data;
}
示例6: onMessage
import org.atmosphere.config.service.Message; //导入依赖的package包/类
@Message(encoders = {DataGsonEncoder.class}, decoders = {DataGsonDecoder.class})
public Data onMessage(Data data) throws IOException {
data.setTime(new Date().getTime());
logger.info("{} just send {}", data.getAuthor(), data.getMessage());
return data;
}
示例7: onMessage
import org.atmosphere.config.service.Message; //导入依赖的package包/类
/**
* Simple annotated class that demonstrate how {@link org.atmosphere.config.managed.Encoder} and {@link org.atmosphere.config.managed.Decoder
* can be used.
*
* @param message an instance of {@link ChatMessage }
* @return the chat message
* @throws IOException
*/
@Message(encoders = {ChatMessageEncoderDecoder.class}, decoders = {ChatMessageEncoderDecoder.class})
public final ChatMessage onMessage(final ChatMessage message) throws IOException{
logger.info("{} just send {}", message.getAuthor(), message.getMessage());
return message;
}