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

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

java 2次浏览

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

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

示例1: getConnection

点赞 3

import org.apache.wicket.protocol.ws.api.IWebSocketConnection; //导入依赖的package包/类
@Override
public IWebSocketConnection getConnection(Application application, String sessionId, IKey key)
{
	Args.notNull(application, "application");
	Args.notNull(sessionId, "sessionId");
	Args.notNull(key, "key");

	IWebSocketConnection connection = null;
	ConcurrentMap<String, ConcurrentMap<IKey, IWebSocketConnection>> connectionsBySession = application.getMetaData(KEY);
	if (connectionsBySession != null)
	{
		ConcurrentMap<IKey, IWebSocketConnection> connectionsByPage = connectionsBySession.get(sessionId);
		if (connectionsByPage != null)
		{
			connection = connectionsByPage.get(key);
		}
	}
	return connection;
}
 

开发者ID:jmfgdev,
项目名称:gitplex-mit,
代码行数:20,
代码来源:SimpleWebSocketConnectionRegistry.java

示例2: getConnections

点赞 3

import org.apache.wicket.protocol.ws.api.IWebSocketConnection; //导入依赖的package包/类
@Override
public Collection<IWebSocketConnection> getConnections(Application application, String sessionId)
{
	Args.notNull(application, "application");
	Args.notNull(sessionId, "sessionId");

	Collection<IWebSocketConnection> connections = Collections.emptyList();
	ConcurrentMap<String, ConcurrentMap<IKey, IWebSocketConnection>> connectionsBySession = application.getMetaData(KEY);
	if (connectionsBySession != null)
	{
		ConcurrentMap<IKey, IWebSocketConnection> connectionsByPage = connectionsBySession.get(sessionId);
		if (connectionsByPage != null)
		{
			connections = connectionsByPage.values();
		}
	}
	return connections;
}
 

开发者ID:jmfgdev,
项目名称:gitplex-mit,
代码行数:19,
代码来源:SimpleWebSocketConnectionRegistry.java

示例3: start

点赞 3

import org.apache.wicket.protocol.ws.api.IWebSocketConnection; //导入依赖的package包/类
@Override
public void start() {
	scheduledExecutorService.scheduleWithFixedDelay(new Runnable() {

		@Override
		public void run() {
			for (IWebSocketConnection connection: new SimpleWebSocketConnectionRegistry().getConnections(application)) {
				if (connection.isOpen()) {
					try {
						connection.sendMessage(WebSocketManager.KEEP_ALIVE);
					} catch (IOException e) {
						throw new RuntimeException(e);
					}
				}
			}
		}
		
	}, 0, webSocketPolicy.getIdleTimeout()/2, TimeUnit.MILLISECONDS);
}
 

开发者ID:jmfgdev,
项目名称:gitplex-mit,
代码行数:20,
代码来源:DefaultWebSocketManager.java

示例4: sendAll

点赞 3

import org.apache.wicket.protocol.ws.api.IWebSocketConnection; //导入依赖的package包/类
private static void sendAll(final String m, boolean publish) {
	if (publish) {
		publish(new WsMessageAll(m));
	}
	Application app = (Application)getApp();
	WebSocketSettings settings = WebSocketSettings.Holder.get(app);
	IWebSocketConnectionRegistry reg = settings.getConnectionRegistry();
	Executor executor = settings.getWebSocketPushMessageExecutor();
	for (IWebSocketConnection c : reg.getConnections(app)) {
		executor.run(() -> {
			try {
				c.sendMessage(m);
			} catch (IOException e) {
				log.error("Error while sending message to ALL", e);
			}
		});
	}
}
 

开发者ID:apache,
项目名称:openmeetings,
代码行数:19,
代码来源:WebSocketHelper.java

示例5: send

点赞 3

import org.apache.wicket.protocol.ws.api.IWebSocketConnection; //导入依赖的package包/类
private static void send(
		final Function<Application, List<Client>> func
		, BiConsumer<IWebSocketConnection, Client> consumer
		, Predicate<Client> check)
{
	Application app = (Application)getApp();
	WebSocketSettings settings = WebSocketSettings.Holder.get(app);
	IWebSocketConnectionRegistry reg = settings.getConnectionRegistry();
	Executor executor = settings.getWebSocketPushMessageExecutor();
	for (Client c : func.apply(app)) {
		if (check == null || check.test(c)) {
			final IWebSocketConnection wc = reg.getConnection(app, c.getSessionId(), new PageIdKey(c.getPageId()));
			if (wc != null && wc.isOpen()) {
				executor.run(() -> consumer.accept(wc, c));
			}
		}
	}
}
 

开发者ID:apache,
项目名称:openmeetings,
代码行数:19,
代码来源:WebSocketHelper.java

示例6: getWebSocketConnection

点赞 3

import org.apache.wicket.protocol.ws.api.IWebSocketConnection; //导入依赖的package包/类
private synchronized IWebSocketConnection getWebSocketConnection()
{
	try
	{
		if (this.asynchronous)
		{
			ThreadContext.restore(this.threadContext);
		}

		return MySession.get().getWebSocketConnection();
	}
	finally
	{
		if (this.asynchronous)
		{
			ThreadContext.detach();
		}
	}
}
 

开发者ID:sebfz1,
项目名称:wicket-quickstart-cdi-async,
代码行数:20,
代码来源:WorkflowListener.java

示例7: getWebSocketConnection

点赞 3

import org.apache.wicket.protocol.ws.api.IWebSocketConnection; //导入依赖的package包/类
public static IWebSocketConnection getWebSocketConnection(WebSocketInfo wsinfo)
{
	IWebSocketConnection connection = null;

	if (wsinfo != null)
	{
		Application application = Application.get(wsinfo.getApplicationName());
		WebSocketSettings settings = WebSocketSettings.Holder.get(application);

		connection = settings.getConnectionRegistry().getConnection(application, wsinfo.getSessionId(), wsinfo.getKey());

		if (connection == null)
		{
			LOG.error("WebSocket connection is lost");
		}
	}
	else
	{
		LOG.error("WebSocket client is unknown");
	}

	return connection;
}
 

开发者ID:sebfz1,
项目名称:wicket-quickstart-cdi-async,
代码行数:24,
代码来源:MySession.java

示例8: pushJsonWebSocketMessage

点赞 2

import org.apache.wicket.protocol.ws.api.IWebSocketConnection; //导入依赖的package包/类
public void pushJsonWebSocketMessage(String json) {
    Application application = Application.get();
    WebSocketSettings settings = WebSocketSettings.Holder.get(application);
    IWebSocketConnectionRegistry registry = settings.getConnectionRegistry();
    IWebSocketConnection connection = registry.getConnection(application, webSocketSessionId, webSocketClientKey);
    if (connection == null) {
        logger.warn("websocket client lookup failed for web-socket session: {}", webSocketSessionId);
        return;
    }
    try {
        connection.sendMessage(json);
    } catch (Exception e) {
        logger.error("websocket push failed", e);
    }
}
 

开发者ID:intuit,
项目名称:karate,
代码行数:16,
代码来源:FeaturePage.java

示例9: sendMessage

点赞 2

import org.apache.wicket.protocol.ws.api.IWebSocketConnection; //导入依赖的package包/类
@Override
public IWebSocketConnection sendMessage(String message) throws IOException
{
	checkClosed();

	session.getRemote().sendStringByFuture(message);
	return this;
}
 

开发者ID:jmfgdev,
项目名称:gitplex-mit,
代码行数:9,
代码来源:WebSocketConnection.java

示例10: doRender

点赞 2

import org.apache.wicket.protocol.ws.api.IWebSocketConnection; //导入依赖的package包/类
private void doRender(WebSocketRegion region, @Nullable PageKey sourcePageKey) {
	for (IWebSocketConnection connection: connectionRegistry.getConnections(application)) {
		PageKey pageKey = ((WebSocketConnection) connection).getPageKey();
		if (connection.isOpen() 
				&& (sourcePageKey == null || !sourcePageKey.equals(pageKey)) 
				&& containsRegion(connection, region)) {
			try {
				connection.sendMessage(RENDER_CALLBACK);
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
	}
}
 

开发者ID:jmfgdev,
项目名称:gitplex-mit,
代码行数:15,
代码来源:DefaultWebSocketManager.java

示例11: containsRegion

点赞 2

import org.apache.wicket.protocol.ws.api.IWebSocketConnection; //导入依赖的package包/类
private boolean containsRegion(IWebSocketConnection connection, WebSocketRegion region) {
	PageKey pageKey = ((WebSocketConnection)connection).getPageKey();
	Collection<WebSocketRegion> connectionRegions = regions.get(pageKey);
	if (connectionRegions != null) {
		for (WebSocketRegion connectionRegion: connectionRegions) {
			if (connectionRegion.contains(region)) {
				return true;
			}
		}
	}
	return false;
}
 

开发者ID:jmfgdev,
项目名称:gitplex-mit,
代码行数:13,
代码来源:DefaultWebSocketManager.java

示例12: send

点赞 2

import org.apache.wicket.protocol.ws.api.IWebSocketConnection; //导入依赖的package包/类
@Override
public void send(IWebSocketPushMessage event) {
	Application application = Application.get(WicketWebInitializer.WICKET_FILTERNAME);
	WebSocketSettings webSocketSettings = WebSocketSettings.Holder.get(application);
	IWebSocketConnectionRegistry connectionRegistry = webSocketSettings.getConnectionRegistry();
	Collection<IWebSocketConnection> connections = connectionRegistry.getConnections(application);
	log.trace("sending event to {} connections", connections.size());
	for (IWebSocketConnection connection : connections) {
		connection.sendMessage(event);
	}
}
 

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

示例13: onMessage

点赞 2

import org.apache.wicket.protocol.ws.api.IWebSocketConnection; //导入依赖的package包/类
@Override
public void onMessage(String message)
{
	LOG.info("WorkflowListener#onMessage: " + message);

	IWebSocketConnection connection = this.getWebSocketConnection();

	if (connection != null && connection.isOpen())
	{
		connection.sendMessage(new StatusMessage(String.valueOf(message)));
	}
}
 

开发者ID:sebfz1,
项目名称:wicket-quickstart-cdi-async,
代码行数:13,
代码来源:WorkflowListener.java

示例14: onException

点赞 2

import org.apache.wicket.protocol.ws.api.IWebSocketConnection; //导入依赖的package包/类
@Override
public void onException(String message)
{
	LOG.info("WorkflowListener#onException: " + message);

	IWebSocketConnection connection = this.getWebSocketConnection();

	if (connection != null && connection.isOpen())
	{
		connection.sendMessage(new ExceptionMessage(String.valueOf(message)));
	}

}
 

开发者ID:sebfz1,
项目名称:wicket-quickstart-cdi-async,
代码行数:14,
代码来源:WorkflowListener.java

示例15: setConnection

点赞 2

import org.apache.wicket.protocol.ws.api.IWebSocketConnection; //导入依赖的package包/类
@Override
public void setConnection(Application application, String sessionId, IKey key, IWebSocketConnection connection)
{
	Args.notNull(application, "application");
	Args.notNull(sessionId, "sessionId");
	Args.notNull(key, "key");

	ConcurrentMap<String, ConcurrentMap<IKey, IWebSocketConnection>> connectionsBySession = application.getMetaData(KEY);
	if (connectionsBySession == null)
	{
		synchronized (KEY)
		{
			connectionsBySession = application.getMetaData(KEY);
			if (connectionsBySession == null)
			{
				connectionsBySession = Generics.newConcurrentHashMap();
				application.setMetaData(KEY, connectionsBySession);
			}
		}
	}

	ConcurrentMap<IKey, IWebSocketConnection> connectionsByPage = connectionsBySession.get(sessionId);
	if (connectionsByPage == null && connection != null)
	{
		connectionsByPage = connectionsBySession.get(sessionId);
		if (connectionsByPage == null)
		{
			connectionsByPage = Generics.newConcurrentHashMap();
			ConcurrentMap<IKey, IWebSocketConnection> old = connectionsBySession.putIfAbsent(sessionId, connectionsByPage);
			if (old != null)
			{
				connectionsByPage = old;
			}
		}
	}

	if (connection != null)
	{
		connectionsByPage.put(key, connection);
	}
	else if (connectionsByPage != null)
	{
		connectionsByPage.remove(key);
		if (connectionsByPage.isEmpty())
		{
			connectionsBySession.remove(sessionId);
		}
	}
}
 

开发者ID:jmfgdev,
项目名称:gitplex-mit,
代码行数:50,
代码来源:SimpleWebSocketConnectionRegistry.java

示例16: sendRoom

点赞 2

import org.apache.wicket.protocol.ws.api.IWebSocketConnection; //导入依赖的package包/类
private static void sendRoom(final Long roomId, BiConsumer<IWebSocketConnection, Client> consumer, Predicate<Client> check) {
	send(a -> ((IApplication)a).getOmRoomClients(roomId), consumer, check);
}
 

开发者ID:apache,
项目名称:openmeetings,
代码行数:4,
代码来源:WebSocketHelper.java


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