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


Java AtmosphereResource.suspend方法代码示例

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


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

示例1: onRequest

import org.atmosphere.cpr.AtmosphereResource; //导入方法依赖的package包/类
@Override
	public void onRequest(AtmosphereResource resource) throws IOException {
//		if (LOG.isTraceEnabled()) {
//			LOG.trace(String.format("onRequest() starts... for resource %s.", resource.uuid()));
//		}
		AtmosphereRequest request = resource.getRequest();

		String method = request.getMethod();
		if ("get".equalsIgnoreCase(method)) {
//			if (LOG.isTraceEnabled()) {
//				LOG.trace("Suspending request after GET call.");
//			}
			UserSession session = null;//sessionsPool.getSessionBySessionId(resource.uuid());
			if (session == null) {
				session = sessionsPool.createSession(resource);
				resource.suspend();
				resource.getResponse().setContentType("application/json");
				getMessageHandler().handleMessage(new MessageContext(sessionsPool, session, null, resource.getRequest().getLocale()));
			}
		} else if ("post".equalsIgnoreCase(method)) {
//			if (LOG.isTraceEnabled()) {
//				LOG.trace("Processing POST message.");
//			}
			HubMessage msg = parseMessage(request);
			if (msg == null) {
				return;
			}
			getMessageHandler().handleMessage(new MessageContext(
					sessionsPool, sessionsPool.getSessionBySessionId(resource.uuid()), msg, resource.getRequest().getLocale()));
		}
 	}
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:32,代码来源:HubAtmosphereHandler.java

示例2: suspend

import org.atmosphere.cpr.AtmosphereResource; //导入方法依赖的package包/类
/**
 * Suspends the given resource
 *
 * @param resource the resource to suspend
 * @since 7.6
 */
protected void suspend(AtmosphereResource resource) {
    if (resource.transport() == TRANSPORT.LONG_POLLING) {
        resource.suspend(getLongPollingSuspendTimeout());
    } else {
        resource.suspend(-1);
    }
}
 
开发者ID:mcollovati,项目名称:vaadin-vertx-samples,代码行数:14,代码来源:VertxPushHandler.java

示例3: handleMessagesApi

import org.atmosphere.cpr.AtmosphereResource; //导入方法依赖的package包/类
/**
 * handleMessagesApi handles all requests sent to /api/messages It
 * suspends/upgrades the connection to a websocket It is a asynchronous
 * protocol - and all messages are wrapped in a message wrapper.
 * 
 * The ApiFactory will handle the details of de-serializing but its necessary
 * to setup some protocol details here for websockets and session management
 * which the ApiFactory should not be concerned with.
 * 
 * @param r - request and response objects from Atmosphere server
 */
public void handleMessagesApi(AtmosphereResource r) {
  try {
    AtmosphereResponse response = r.getResponse();
    AtmosphereRequest request = r.getRequest();
    OutputStream out = response.getOutputStream();

    if (!r.isSuspended()) {
      r.suspend();
    }
    response.addHeader("Content-Type", CodecUtils.MIME_TYPE_JSON);

    api.process(this, out, r.getRequest().getRequestURI(), request.body().asString());

    /*
     * // FIXME - GET or POST should work - so this "should" be unnecessary ..
     * if ("GET".equals(httpMethod)) { // if post and parts.length < 3 ?? //
     * respond(r, apiKey, "getPlatform", new Hello(Runtime.getId()));
     * HashMap<URI, ServiceEnvironment> env = Runtime.getEnvironments();
     * respond(r, apiKey, "getLocalServices", env); } else {
     * doNotUseThisProcessMessageAPI(codec, request.body()); // FIXME data is
     * double encoded .. can't put '1st' encoded json // api.process(this,
     * out, r.getRequest().getRequestURI(), request.body().asString()); }
     */

  } catch (Exception e) {
    log.error("handleMessagesApi -", e);
  }
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:40,代码来源:WebGui.java


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