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


Java ClientManager.createClient方法代码示例

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


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

示例1: connectToKillJob

import org.glassfish.tyrus.client.ClientManager; //导入方法依赖的package包/类
/**
 * Instantiates HydrographUiClientSocket and establishes connection with
 * server in order to kill the job.
 *
 * @param jobID the job id
 * @param url the url
 * @return Session
 * @throws Throwable the throwable
 */
public Session connectToKillJob(String jobID, String url) throws Throwable {

	try {

		HydrographUiClientSocket socket = new HydrographUiClientSocket();
		ClientManager clientManager = ClientManager.createClient();
		Session session = clientManager.connectToServer(socket,
				new URI(url));
		socket.sendMessage(getKillReq(jobID));
		Thread.sleep(3000);
		return session;

	} catch (Throwable t) {
		throw t;
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:26,代码来源:HydrographServerConnection.java

示例2: initWebSocketSession

import org.glassfish.tyrus.client.ClientManager; //导入方法依赖的package包/类
private void initWebSocketSession(String url, int wsConnectionTimeout) throws Exception {
    CountDownLatch wsLatch = new CountDownLatch(1);
    ClientEndpointConfig cec = ClientEndpointConfig.Builder.create().build();
    ClientManager client = ClientManager.createClient();

    client.connectToServer(new Endpoint() {
        @Override
        public void onOpen(Session session, EndpointConfig endpointConfig) {
            wsSession = session;
            wsLatch.countDown();
        }
    }, cec, new URI(url));

    if (!wsLatch.await(wsConnectionTimeout, TimeUnit.SECONDS)) {
        throw new TimeoutException("Web socket connection timeout");
    }
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:18,代码来源:LogEventHandler.java

示例3: run

import org.glassfish.tyrus.client.ClientManager; //导入方法依赖的package包/类
@Override
public void run(AtomicBoolean running) throws Exception {

  System.out.println("Opening GPIO...");
  ClientManager client = ClientManager.createClient();

  try (GPIOPin led17 = DeviceManager.open(GPIOPin.class, led17config);
          GPIOPin led4 = DeviceManager.open(GPIOPin.class, led4config);
          GPIOPin led22 = DeviceManager.open(GPIOPin.class, led22config);
          Session websocket = client.connectToServer(new LedManager(led17, led4, led22), URI.create("ws://192.168.1.10:8080/SensorPanel/ws/notifications/temperature"))) {
    System.out.println("Main loop started.");
    while (running.get()) {
      Thread.sleep(1000);
    }
    led17.setValue(false);
    led4.setValue(false);
    led22.setValue(false);
  }
}
 
开发者ID:emoranchel,项目名称:SensorPanel,代码行数:20,代码来源:WebSockletRunner.java

示例4: connect

import org.glassfish.tyrus.client.ClientManager; //导入方法依赖的package包/类
public synchronized void connect(String server) {
    /**
     * Only connect once, which is intended to stay connected forever. If
     * manually disconnecting/connecting again should be a thing, some stuff
     * may have to be changed.
     */
    if (connecting) {
        return;
    }
    connecting = true;
    try {
        LOGGER.info("[PubSub] Connecting to "+server);
        ClientManager clientManager = ClientManager.createClient();
        clientManager.getProperties().put(ClientProperties.RECONNECT_HANDLER, new Reconnect());
        clientManager.asyncConnectToServer(this, new URI(server));
    } catch (Exception ex) {
        LOGGER.warning("[PubSub] Error connecting "+ex);
    }
}
 
开发者ID:chatty,项目名称:chatty,代码行数:20,代码来源:Client.java

示例5: prepareConnection

import org.glassfish.tyrus.client.ClientManager; //导入方法依赖的package包/类
/**
 * Create and configure a Client Manager.
 */
private void prepareConnection() {
    clientManager = ClientManager.createClient();
    clientManager.getProperties().put(ClientProperties.RECONNECT_HANDLER, new Reconnect());

    // Try to add Let's Encrypt cert for SSL
    try {
        SslEngineConfigurator sslEngineConfigurator = new SslEngineConfigurator(
                SSLUtil.getSSLContextWithLE(), true, false, false);
        clientManager.getProperties().put(ClientProperties.SSL_ENGINE_CONFIGURATOR, sslEngineConfigurator);
        ssl = true;
    } catch (Exception ex) {
        LOGGER.warning("Failed adding support for Lets Encrypt: " + ex);
        ssl = false;
    }
}
 
开发者ID:chatty,项目名称:chatty,代码行数:19,代码来源:WebsocketClient.java

示例6: connect

import org.glassfish.tyrus.client.ClientManager; //导入方法依赖的package包/类
@Override
public synchronized CompletableFuture<SqpConnection> connect(String host, int port, String path, String database) {
    _state = ConnectionState.Connecting;
    _database = database;
    ClientManager clientManager = ClientManager.createClient();
    ClientEndpointConfig cec = ClientEndpointConfig.Builder.create().build();
    String scheme = "ws";
    _connectionFuture = new CompletableFuture<>();

    URI uri;
    try {
        uri = new URI(scheme, null, host, port, path, null, null);
        _logger.log(Level.INFO, "Attempting to connect to '" + uri + "'");
        clientManager.connectToServer(this, cec, uri);
    } catch (URISyntaxException | DeploymentException | IOException e) {
        _connectionFuture.completeExceptionally(new ConnectionException("Failed to connect to server: " + e.getMessage(), e));
    }
    return _connectionFuture;
}
 
开发者ID:SimpleQueryProtocol,项目名称:sqp,代码行数:20,代码来源:SqpConnectionImpl.java

示例7: testCreateWebSoketClient

import org.glassfish.tyrus.client.ClientManager; //导入方法依赖的package包/类
@Test
public void testCreateWebSoketClient() throws Exception {
    SlackWebsocketConnection slack = new SlackWebsocketConnection("token", null, 8080);

    SlackAuthen slackAuthen = PowerMockito.mock(SlackAuthen.class);
    PowerMockito.whenNew(SlackAuthen.class).withNoArguments().thenReturn(slackAuthen);
    PowerMockito.when(slackAuthen.tokenAuthen(Mockito.anyString(), Mockito.anyString(), Mockito.anyInt())).thenReturn(slackInfo);

    ClientManager clientManager = PowerMockito.mock(ClientManager.class);
    PowerMockito.mockStatic(ClientManager.class);
    PowerMockito.when(ClientManager.createClient()).thenReturn(clientManager);

    boolean connect = slack.connect();
    assertThat(connect, is(true));

    PowerMockito.verifyStatic();
    ClientManager.createClient();
}
 
开发者ID:mockupcode,项目名称:slack-rtm-api,代码行数:19,代码来源:SlackWebsocketConnectionTest.java

示例8: testCreateWebSoketClientWithProxy

import org.glassfish.tyrus.client.ClientManager; //导入方法依赖的package包/类
@Test
public void testCreateWebSoketClientWithProxy() throws Exception {
    SlackWebsocketConnection slack = new SlackWebsocketConnection("token", "proxy", 8080);

    SlackAuthen slackAuthen = PowerMockito.mock(SlackAuthen.class);
    PowerMockito.whenNew(SlackAuthen.class).withNoArguments().thenReturn(slackAuthen);
    PowerMockito.when(slackAuthen.tokenAuthen(Mockito.anyString(), Mockito.anyString(), Mockito.anyInt())).thenReturn(slackInfo);

    ClientManager clientManager = PowerMockito.mock(ClientManager.class);
    PowerMockito.mockStatic(ClientManager.class);
    PowerMockito.when(ClientManager.createClient()).thenReturn(clientManager);
    Map<String, Object> properties = Mockito.mock(Map.class);
    PowerMockito.when(clientManager.getProperties()).thenReturn(properties);

    boolean connect = slack.connect();
    assertThat(connect, is(true));

    Mockito.verify(clientManager.getProperties()).put(Mockito.eq(ClientProperties.PROXY_URI), Mockito.anyString());
    PowerMockito.verifyStatic();
    ClientManager.createClient();
}
 
开发者ID:mockupcode,项目名称:slack-rtm-api,代码行数:22,代码来源:SlackWebsocketConnectionTest.java

示例9: testCreateWebSocketAndConnectToServer

import org.glassfish.tyrus.client.ClientManager; //导入方法依赖的package包/类
@Test
public void testCreateWebSocketAndConnectToServer() throws Exception {
    SlackWebsocketConnection slack = new SlackWebsocketConnection("token", null, 8080);

    SlackAuthen slackAuthen = PowerMockito.mock(SlackAuthen.class);
    PowerMockito.whenNew(SlackAuthen.class).withNoArguments().thenReturn(slackAuthen);
    PowerMockito.when(slackAuthen.tokenAuthen(Mockito.anyString(), Mockito.anyString(), Mockito.anyInt())).thenReturn(slackInfo);

    ClientManager clientManager = PowerMockito.mock(ClientManager.class);
    PowerMockito.mockStatic(ClientManager.class);
    PowerMockito.when(ClientManager.createClient()).thenReturn(clientManager);

    boolean connect = slack.connect();
    assertThat(connect, is(true));

    Mockito.verify(clientManager).connectToServer(Mockito.any(Endpoint.class), Mockito.any(URI.class));
    PowerMockito.verifyStatic();
    ClientManager.createClient();
}
 
开发者ID:mockupcode,项目名称:slack-rtm-api,代码行数:20,代码来源:SlackWebsocketConnectionTest.java

示例10: run

import org.glassfish.tyrus.client.ClientManager; //导入方法依赖的package包/类
@Override
public void run() {
    ClientManager client = ClientManager.createClient();
    try {
        URI uri = new URI(ApiAware.withUrl(apiProvider.getBaseUri()).getWebSocketUrl("mail"));
        client.getProperties().put(ClientProperties.RECONNECT_HANDLER, new ReconnectHandler());
        client.connectToServer(
                new MailClientEndpoint(),
                ClientEndpointConfig.Builder.create().build(),
                uri
        );
        countDownLatch.await();
        client.shutdown();
    } catch (Exception e) {
        logger.warn(String.format(
                "Failed to connect to mail endpoint. Mail functionality is disabled. Error is: %s",
                e.getMessage()
        ));
    }
}
 
开发者ID:meridor,项目名称:perspective-backend,代码行数:21,代码来源:MailRepositoryImpl.java

示例11: setUp

import org.glassfish.tyrus.client.ClientManager; //导入方法依赖的package包/类
@Before
    public void setUp() throws Exception {

        this.client = HttpClients.custom()
                .setServiceUnavailableRetryStrategy(new DefaultServiceUnavailableRetryStrategy(3, 2000))
                .setDefaultRequestConfig(RequestConfig.custom()
                        .setSocketTimeout(10000)
                        .setConnectTimeout(10000)
                        .setConnectionRequestTimeout(10000)
                        .build()).build();
        this.om = new ObjectMapper();
        this.wsClient = ClientManager.createClient();
        wsClient.getProperties().put(ClientProperties.HANDSHAKE_TIMEOUT, 10000);        
            if (System.getProperty(TRAVIS_ENV) != null) {
                System.out.println("waiting for Travis machine");
                waitUrlAvailable(String.format("http://%s:%d/api?name=foo", LOCALHOST, PORT));
//                Thread.sleep(1); // Ugly sleep to debug travis            
            }
    }
 
开发者ID:LivePersonInc,项目名称:dropwizard-websockets,代码行数:20,代码来源:DropWizardWebsocketsTest.java

示例12: connectToServer

import org.glassfish.tyrus.client.ClientManager; //导入方法依赖的package包/类
/**
 * Instantiates HydrographUiClientSocket and establishes connection with
 * server in order to get execution status.
 *
 * @param job the job
 * @param jobID the job id
 * @param url the url
 * @return Session
 */
public Session connectToServer(final Job job, String jobID, String url) {
	Session session = null;
	counter++;
	try {
		HydrographUiClientSocket socket = new HydrographUiClientSocket();
		ClientManager clientManager = ClientManager.createClient();
		session = clientManager.connectToServer(socket, new URI(url));
		socket.sendMessage(getStatusReq(jobID));
		return session;

	} catch (Throwable t) {
		if (counter > 1) {
				Display.getDefault().asyncExec(new Runnable() {
					@Override
					public void run() {
						messageDialogForExecutionTracking(job, Display
								.getDefault().getActiveShell());

					}
				});
				
				logger.error("Error while connection to server");
			}else{
				session = connectToServer(job, jobID, url);

		}
		return session;
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:39,代码来源:HydrographServerConnection.java

示例13: getWebSocketContainer

import org.glassfish.tyrus.client.ClientManager; //导入方法依赖的package包/类
@Override
public WebSocketContainer getWebSocketContainer()
{
    ClientManager clientManager = ClientManager.createClient();
    if (proxyAddress != null)
    {
        clientManager.getProperties().put(ClientProperties.PROXY_URI, "http://" + proxyAddress + ":" + proxyPort);
    }
    return clientManager;
}
 
开发者ID:riversun,项目名称:slacklet,代码行数:11,代码来源:DefaultWebSocketContainerProvider.java

示例14: testSendLetter

import org.glassfish.tyrus.client.ClientManager; //导入方法依赖的package包/类
@Test
public void testSendLetter() throws Exception {
    putLetterToQueue(FIRST_LETTER); //This one goes to cache as no client connection exists
    ClientManager client = ClientManager.createClient();
    URI endpoint = new URI(ApiAware.withUrl(server.getBaseUrl()).getWebSocketUrl("mail"));
    client.connectToServer(this, endpoint);
    connectionLatch.await();
    putLetterToQueue(SECOND_LETTER); //This one should be sent immediately
    receiveLatch.await();
    assertThat(exceptions, is(empty()));
    assertThat(letters, containsInAnyOrder(FIRST_LETTER, SECOND_LETTER));
}
 
开发者ID:meridor,项目名称:perspective-backend,代码行数:13,代码来源:MailResourceTest.java

示例15: main

import org.glassfish.tyrus.client.ClientManager; //导入方法依赖的package包/类
public static void main(String[] args) {
    latch = new CountDownLatch(1);

    ClientManager client = ClientManager.createClient();
    try {
        System.out.println("Connecting");
        client.connectToServer(WebSocketClient.class, new URI("ws://localhost:9400/ws/_changes"));
        System.out.println("Connected");
        latch.await();

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:ForgeRock,项目名称:es-change-feed-plugin,代码行数:15,代码来源:WebSocketClient.java


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