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

Java UpgradeRequest类代码示例

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

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



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

示例1: getPrincipalFromNativeSession

import org.eclipse.jetty.websocket.api.UpgradeRequest; //导入依赖的package包/类
@Test
public void getPrincipalFromNativeSession() {

	TestPrincipal user = new TestPrincipal("joe");

	UpgradeRequest request = Mockito.mock(UpgradeRequest.class);
	given(request.getUserPrincipal()).willReturn(user);

	UpgradeResponse response = Mockito.mock(UpgradeResponse.class);
	given(response.getAcceptedSubProtocol()).willReturn(null);

	Session nativeSession = Mockito.mock(Session.class);
	given(nativeSession.getUpgradeRequest()).willReturn(request);
	given(nativeSession.getUpgradeResponse()).willReturn(response);

	JettyWebSocketSession session = new JettyWebSocketSession(attributes);
	session.initializeNativeSession(nativeSession);

	reset(nativeSession);

	assertSame(user, session.getPrincipal());
	verifyNoMoreInteractions(nativeSession);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:JettyWebSocketSessionTests.java


示例2: getPrincipalNotAvailable

import org.eclipse.jetty.websocket.api.UpgradeRequest; //导入依赖的package包/类
@Test
public void getPrincipalNotAvailable() {

	UpgradeRequest request = Mockito.mock(UpgradeRequest.class);
	given(request.getUserPrincipal()).willReturn(null);

	UpgradeResponse response = Mockito.mock(UpgradeResponse.class);
	given(response.getAcceptedSubProtocol()).willReturn(null);

	Session nativeSession = Mockito.mock(Session.class);
	given(nativeSession.getUpgradeRequest()).willReturn(request);
	given(nativeSession.getUpgradeResponse()).willReturn(response);

	JettyWebSocketSession session = new JettyWebSocketSession(attributes);
	session.initializeNativeSession(nativeSession);

	reset(nativeSession);

	assertNull(session.getPrincipal());
	verifyNoMoreInteractions(nativeSession);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:JettyWebSocketSessionTests.java


示例3: getAcceptedProtocol

import org.eclipse.jetty.websocket.api.UpgradeRequest; //导入依赖的package包/类
@Test
public void getAcceptedProtocol() {

	String protocol = "foo";

	UpgradeRequest request = Mockito.mock(UpgradeRequest.class);
	given(request.getUserPrincipal()).willReturn(null);

	UpgradeResponse response = Mockito.mock(UpgradeResponse.class);
	given(response.getAcceptedSubProtocol()).willReturn(protocol);

	Session nativeSession = Mockito.mock(Session.class);
	given(nativeSession.getUpgradeRequest()).willReturn(request);
	given(nativeSession.getUpgradeResponse()).willReturn(response);

	JettyWebSocketSession session = new JettyWebSocketSession(attributes);
	session.initializeNativeSession(nativeSession);

	reset(nativeSession);

	assertSame(protocol, session.getAcceptedProtocol());
	verifyNoMoreInteractions(nativeSession);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:JettyWebSocketSessionTests.java


示例4: createWebSocket

import org.eclipse.jetty.websocket.api.UpgradeRequest; //导入依赖的package包/类
@Override
public Object createWebSocket(UpgradeRequest request, UpgradeResponse response) {

    // Validate and use "guacamole" subprotocol
    for (String subprotocol : request.getSubProtocols()) {

        if ("guacamole".equals(subprotocol)) {
            response.setAcceptedSubProtocol(subprotocol);
            return new RestrictedGuacamoleWebSocketTunnelListener(tunnelRequestService);
        }

    }

    // Invalid protocol
    return null;

}
 
开发者ID:apache,项目名称:guacamole-client,代码行数:18,代码来源:RestrictedGuacamoleWebSocketCreator.java


示例5: invoke

import org.eclipse.jetty.websocket.api.UpgradeRequest; //导入依赖的package包/类
public ValidateUpgradeRequest invoke() {
    UpgradeRequest request = session.getUpgradeRequest();
    URI uri = request.getRequestURI();
    path = uri.getPath();
    Map<String, List<String>> params = request.getParameterMap();
    List<String> watch = params.get("watch");
    LOG.debug("path: {}", path);
    if (watch == null || watch.size() != 1) {
        session.close(0, " must specify watch parameter when connecting via websocket");
        myResult = true;
        return this;
    }
    if (!watch.get(0).equalsIgnoreCase("true")) {
        session.close(0, " must specify watch parameter equal to 'true' when connecting via websocket");
        myResult = true;
        return this;
    }
    myResult = false;
    return this;
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:21,代码来源:WatchWebSocket.java


示例6: setup

import org.eclipse.jetty.websocket.api.UpgradeRequest; //导入依赖的package包/类
@Before
public void setup() {
	this.session = mock(Session.class);
	given(this.session.getUpgradeRequest()).willReturn(Mockito.mock(UpgradeRequest.class));
	given(this.session.getUpgradeResponse()).willReturn(Mockito.mock(UpgradeResponse.class));

	this.webSocketHandler = mock(WebSocketHandler.class);
	this.webSocketSession = new JettyWebSocketSession(null, null);
	this.adapter = new JettyWebSocketHandlerAdapter(this.webSocketHandler, this.webSocketSession);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:JettyWebSocketHandlerAdapterTests.java


示例7: configure

import org.eclipse.jetty.websocket.api.UpgradeRequest; //导入依赖的package包/类
@Override
public void configure(WebSocketServletFactory factory) {
  // Most implementations of this method simply invoke factory.register(DispatchSocket.class);
  // however, that requires DispatchSocket to have a no-arg constructor. That does not work for
  // us because we would like all WebSockets created by this factory to have a reference to this
  // parent class. This is why we override the default WebSocketCreator for the factory.
  WebSocketCreator wrapperCreator = new WebSocketCreator() {
    @Override
    public Object createWebSocket(UpgradeRequest req, UpgradeResponse resp) {
      return new MyWebSocket();
    }
  };
  factory.setCreator(wrapperCreator);
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:15,代码来源:StreamingWebSocketServlet.java


示例8: parseStartLine

import org.eclipse.jetty.websocket.api.UpgradeRequest; //导入依赖的package包/类
private long parseStartLine(UpgradeRequest request) {
    Optional<NameValuePair> startLine = URLEncodedUtils.parse(request.getRequestURI(), "UTF-8").
            stream().
            filter(new Predicate<NameValuePair>() {
                @Override
                public boolean test(NameValuePair pair) {
                    return "startLine".equals(pair.getName());
                }
            }).findFirst();

    return startLine.isPresent() ? Long.valueOf(startLine.get().getValue()) : 0L;
}
 
开发者ID:gocd,项目名称:gocd,代码行数:13,代码来源:ConsoleLogSocket.java


示例9: createWebSocket

import org.eclipse.jetty.websocket.api.UpgradeRequest; //导入依赖的package包/类
@Override
  public Object createWebSocket(UpgradeRequest req, UpgradeResponse resp) {  
  	System.out.println(".. "+req.getRequestURI().getPath());
  	String path = req.getRequestURI().getPath(),
  		   name = path.substring(path.lastIndexOf('/')+1); 

try {

	Class<?> clazz = Class.forName("jforex.jetty."+name.substring(0, 1).toUpperCase() + name.substring(1)+"Strategy");
	
	Object strat = null;
	for (Entry<Long, IStrategy> e : WebServer.pids.entrySet()){
  			if (clazz.equals(e.getValue().getClass())){
  				strat = e.getValue();
  			}
	}
	// if not started, start it now
	if (strat ==null){
		Constructor<?> ctor = clazz.getConstructor();
		strat = ctor.newInstance();
    	long pid = ClientFactory.getDefaultInstance().startStrategy((IStrategy) strat);
    	WebServer.pids.put(pid, (IStrategy) strat);
	}
	return strat;

} catch (ClassNotFoundException | SecurityException | IllegalArgumentException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e1) {
	e1.printStackTrace();
}

      return null;
  }
 
开发者ID:caub,项目名称:JForexJetty,代码行数:32,代码来源:WsServlet.java


示例10: getHttpRequest

import org.eclipse.jetty.websocket.api.UpgradeRequest; //导入依赖的package包/类
private HttpServletRequest getHttpRequest(UpgradeRequest request)  {       
    try {
        return (HttpServletRequest) requestField.get(request);    
    } catch (Exception e) {
        throw new IllegalStateException("Could not get HTTP request from field", e);
    }
}
 
开发者ID:wigforss,项目名称:Ka-Websocket,代码行数:8,代码来源:Jetty9WebsocketCreator.java


示例11: configure

import org.eclipse.jetty.websocket.api.UpgradeRequest; //导入依赖的package包/类
@Override
public void configure(WebSocketServletFactory factory) {
    factory.getPolicy().setIdleTimeout(10000);
    factory.setCreator(new WebSocketCreator() {
            @Override
            public Object createWebSocket(UpgradeRequest req, UpgradeResponse resp) {
                return new DrogonLoggerSocket( getWebLoggerModule( ) );
            }
        });
}
 
开发者ID:joemonti,项目名称:drogon-master,代码行数:11,代码来源:DrogonLoggerServlet.java


示例12: getUpgradeRequest

import org.eclipse.jetty.websocket.api.UpgradeRequest; //导入依赖的package包/类
@Override
public UpgradeRequest getUpgradeRequest() {
  return null;
}
 
开发者ID:facebook,项目名称:buck,代码行数:5,代码来源:MockSession.java


示例13: WebSocketTunnelRequest

import org.eclipse.jetty.websocket.api.UpgradeRequest; //导入依赖的package包/类
/**
 * Creates a TunnelRequest implementation which delegates parameter and
 * session retrieval to the given UpgradeRequest.
 *
 * @param request The UpgradeRequest to wrap.
 */
public WebSocketTunnelRequest(UpgradeRequest request) {
    this.handshakeParameters = request.getParameterMap();
}
 
开发者ID:apache,项目名称:guacamole-client,代码行数:10,代码来源:WebSocketTunnelRequest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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