Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduction of Draft_6455 #483

Merged
merged 1 commit into from
May 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/example/ChatClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.java_websocket.WebSocketImpl;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft;
import org.java_websocket.drafts.Draft_17;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.handshake.ServerHandshake;

public class ChatClient extends JFrame implements ActionListener {
Expand All @@ -38,7 +38,7 @@ public ChatClient( String defaultlocation ) {
layout.setRows( 6 );
c.setLayout( layout );

Draft[] drafts = { new Draft_17() };
Draft[] drafts = { new Draft_6455() };
draft = new JComboBox( drafts );
c.add( draft );

Expand Down
4 changes: 2 additions & 2 deletions src/main/example/ExampleClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft;
import org.java_websocket.drafts.Draft_17;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.framing.Framedata;
import org.java_websocket.handshake.ServerHandshake;

Expand Down Expand Up @@ -47,7 +47,7 @@ public void onError( Exception ex ) {
}

public static void main( String[] args ) throws URISyntaxException {
ExampleClient c = new ExampleClient( new URI( "ws://localhost:8887" ), new Draft_17() ); // more about drafts here: http://github.com/TooTallNate/Java-WebSocket/wiki/Drafts
ExampleClient c = new ExampleClient( new URI( "ws://localhost:8887" ), new Draft_6455() ); // more about drafts here: http://github.com/TooTallNate/Java-WebSocket/wiki/Drafts
c.connect();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/example/FragmentedFramesExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import org.java_websocket.WebSocket;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_17;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.framing.Framedata.Opcode;

/**
Expand All @@ -22,7 +22,7 @@ public class FragmentedFramesExample {
public static void main( String[] args ) throws URISyntaxException , IOException , InterruptedException {
// WebSocketImpl.DEBUG = true; // will give extra output

WebSocketClient websocket = new ExampleClient( new URI( "ws://localhost:8887" ), new Draft_17() ); // Draft_17 is implementation of rfc6455
WebSocketClient websocket = new ExampleClient( new URI( "ws://localhost:8887" ), new Draft_6455() ); // Draft_6455 is implementation of rfc6455
if( !websocket.connectBlocking() ) {
System.err.println( "Could not connect to the server." );
return;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/java_websocket/WebSocketImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class WebSocketImpl implements WebSocket {
public static/*final*/ boolean DEBUG = false; // must be final in the future in order to take advantage of VM optimization

static {
defaultdraftlist.add( new Draft_17() );
defaultdraftlist.add( new Draft_6455() );
}

/**
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/org/java_websocket/client/WebSocketClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@

import org.java_websocket.AbstractWebSocket;
import org.java_websocket.WebSocket;
import org.java_websocket.WebSocketAdapter;
import org.java_websocket.WebSocketImpl;
import org.java_websocket.drafts.Draft;
import org.java_websocket.drafts.Draft_17;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.exceptions.InvalidHandshakeException;
import org.java_websocket.framing.CloseFrame;
import org.java_websocket.framing.Framedata;
import org.java_websocket.framing.Framedata.Opcode;
import org.java_websocket.framing.FramedataImpl1;
import org.java_websocket.handshake.HandshakeImpl1Client;
import org.java_websocket.handshake.Handshakedata;
import org.java_websocket.handshake.ServerHandshake;
Expand Down Expand Up @@ -70,7 +68,7 @@ public abstract class WebSocketClient extends AbstractWebSocket implements Runna
* @param serverUri the server URI to connect to
*/
public WebSocketClient( URI serverUri ) {
this( serverUri, new Draft_17() );
this( serverUri, new Draft_6455());
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/java_websocket/drafts/Draft_17.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import org.java_websocket.handshake.ClientHandshake;
import org.java_websocket.handshake.ClientHandshakeBuilder;

/**
* Implementation of the Hybi 17 Draft
* Please use the Draft_6455 for your websocket implementation
*/
@Deprecated
public class Draft_17 extends Draft_10 {
@Override
public HandshakeState acceptHandshakeAsServer( ClientHandshake handshakedata ) throws InvalidHandshakeException {
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/org/java_websocket/drafts/Draft_6455.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.java_websocket.drafts;

/**
* Implementation for the RFC 6455 websocket protocol
* This is the recommended class for your websocket connection
*/
public class Draft_6455 extends Draft_17 {

@Override
public Draft copyInstance() {
return new Draft_6455();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.java_websocket.WebSocketImpl;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft;
import org.java_websocket.drafts.Draft_17;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.framing.FrameBuilder;
import org.java_websocket.framing.Framedata;
import org.java_websocket.handshake.ServerHandshake;
Expand All @@ -37,12 +37,12 @@ public static void main( String[] args ) {
BufferedReader sysin = new BufferedReader( new InputStreamReader( System.in ) );

/*First of the thinks a programmer might want to change*/
Draft d = new Draft_17();
Draft d = new Draft_6455();
String clientname = "tootallnate/websocket";

String protocol = "ws";
String host = "localhost";
int port = 9001;
int port = 9003;

String serverlocation = protocol + "://" + host + ":" + port;
String line = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.java_websocket.WebSocket;
import org.java_websocket.WebSocketImpl;
import org.java_websocket.drafts.Draft;
import org.java_websocket.drafts.Draft_17;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.framing.FrameBuilder;
import org.java_websocket.framing.Framedata;
import org.java_websocket.handshake.ClientHandshake;
Expand Down Expand Up @@ -73,7 +73,8 @@ public static void main( String[] args ) throws UnknownHostException {
System.out.println( "No port specified. Defaulting to 9003" );
port = 9003;
}
new AutobahnServerTest( port, new Draft_17() ).start();
AutobahnServerTest test = new AutobahnServerTest( port, new Draft_6455() );
test.start();
}

}