-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebSocketClient.java
More file actions
34 lines (29 loc) · 957 Bytes
/
WebSocketClient.java
File metadata and controls
34 lines (29 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.javaee7.chapter09;
import java.io.IOException;
import java.net.URI;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.websocket.ContainerProvider;
import javax.websocket.DeploymentException;
import javax.websocket.WebSocketContainer;
import javax.ws.rs.client.Client;
/**
*
* @author Juneau
*/
public class WebSocketClient {
public static void main(String[] args) {
try {
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
String uri = "ws://localhost:8080";
System.out.println("Connecting to " + uri);
container.connectToServer(AcmeChatClient.class, URI.create(uri));
} catch (DeploymentException | IOException ex) {
Logger.getLogger(Client.class.getName()).log(Level.SEVERE, null, ex);
}
}
}