• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java WebSocketRequestHandler类的典型用法和代码示例

java 1次浏览

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

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

示例1: CustomerListPage

点赞 2

import org.apache.wicket.protocol.ws.api.WebSocketRequestHandler; //导入依赖的package包/类
public CustomerListPage() {
	FeedbackPanel feedbackPanel = new FeedbackPanel("feedback");
	feedbackPanel.setOutputMarkupId(true);
	add(feedbackPanel);
	
	add(new WebSocketBehavior() {

		@Override
		protected void onPush(WebSocketRequestHandler handler, IWebSocketPushMessage message) {
			if (message instanceof CustomerChangedEvent) {
				CustomerChangedEvent event = (CustomerChangedEvent)message;
				info("changed/created " + event.getCustomer().getFirstname() + " " + event.getCustomer().getLastname());
				handler.add(feedbackPanel);
			}
		}

	});
	
	customerFilterModel = new CompoundPropertyModel<>(new CustomerFilter());
	CustomerDataProvider customerDataProvider = new CustomerDataProvider(customerFilterModel);
	
	queue(new BookmarkablePageLink<Customer>("create", CustomerCreatePage.class));
	
	queue(new ValidationForm<>("form", customerFilterModel));
	queue(new LabeledFormBorder<>(getString("id"), new TextField<>("id")));
	queue(new LabeledFormBorder<>(getString("username"), new UsernameSearchTextField("usernameLike")));
	queue(new LabeledFormBorder<>(getString("firstname"), new TextField<String>("firstnameLike").add(StringValidator.minimumLength(3))));
	queue(new LabeledFormBorder<>(getString("lastname"), new TextField<String>("lastnameLike").add(StringValidator.minimumLength(3))));
	queue(new LabeledFormBorder<>(getString("active"), new CheckBox("active")));
	queue(cancelButton());
	
	customerDataTable(customerDataProvider);

}
 

开发者ID:MarcGiffing,
项目名称:wicket-spring-boot,
代码行数:35,
代码来源:CustomerListPage.java

示例2: onMessage

点赞 2

import org.apache.wicket.protocol.ws.api.WebSocketRequestHandler; //导入依赖的package包/类
@Override
protected void onMessage(final WebSocketRequestHandler handler, final TextMessage message) {
    try {
        JsonNode obj = OBJECT_MAPPER.readTree(message.getText());

        switch (Topology.SupportedOperation.valueOf(obj.get("kind").asText())) {
            case CHECK_CONNECTOR:
                final String ckey = obj.get("target").asText();

                if (connectors.containsKey(ckey)) {
                    handler.push(connectors.get(ckey));
                } else {
                    handler.push(String.format(
                            "{ \"status\": \"%s\", \"target\": \"%s\"}", TopologyNode.Status.UNKNOWN, ckey));
                }

                if (runningConnCheck.contains(ckey)) {
                    LOG.debug("Running connection check for connector {}", ckey);
                } else {
                    runningConnCheck.add(ckey);
                }

                SyncopeConsoleSession.get().execute(new ConnCheck(ckey));

                break;
            case CHECK_RESOURCE:
                final String rkey = obj.get("target").asText();

                if (resources.containsKey(rkey)) {
                    handler.push(resources.get(rkey));
                } else {
                    handler.push(String.format(
                            "{ \"status\": \"%s\", \"target\": \"%s\"}", TopologyNode.Status.UNKNOWN, rkey));
                }

                if (runningResCheck.contains(rkey)) {
                    LOG.debug("Running connection check for resource {}", rkey);
                } else {
                    runningResCheck.add(rkey);
                }

                SyncopeConsoleSession.get().execute(new ResCheck(rkey));

                break;
            case ADD_ENDPOINT:
                handler.appendJavaScript(String.format("addEndpoint('%s', '%s', '%s');",
                        obj.get("source").asText(),
                        obj.get("target").asText(),
                        obj.get("scope").asText()));
                break;
            default:
        }
    } catch (IOException e) {
        LOG.error("Eror managing websocket message", e);
    }
}
 

开发者ID:apache,
项目名称:syncope,
代码行数:57,
代码来源:TopologyWebSocketBehavior.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)