Skip to content

better usability - #74

Merged
TooTallNate merged 29 commits into
TooTallNate:masterfrom
Davidiusdadi:master
Mar 5, 2012
Merged

TooTallNate merged 29 commits into
TooTallNate:masterfrom
Davidiusdadi:master

Conversation

@Davidiusdadi

Copy link
Copy Markdown
Collaborator

This pull request smooths out some method signatures. The methods are now more similar to the ones used in javascript.

Changes

  • a bunch of methods were made final since they are not indented to be overwritten. If your compiler complains note that these methods have abstract companions which are indented to be overwritten instead.
  • a bunch of methods were renamed
    • most methods in the src/net/tootallnate/websocket/WebSocketListener.java. Since these methods are used all over the project a bunch of files were also touched.
    • the names of the abstract methods in websocket/WebSocketServer.java were named according the their counterparts in the websocket/WebSocketClient.java
  • the package structure was updated.
  • the handshake classes and methods were updated

I will keep breaking changes which force users to change their implementing code as seldom as possible!

@TooTallNate

Copy link
Copy Markdown
Owner

I think these changes along with the package being renamed to org.java_websocket.* will make up our v1.0.0 release :)

Davidiusdadi and others added 8 commits March 2, 2012 22:26
…stener interface.

This is fired BEFORE the Http Handshake Request is sent.
The same request object is passed again, together with the Response, when the Http Handshake Response is received.
…ttp Status (Message) and Http Method, as needed.
@Davidiusdadi

Copy link
Copy Markdown
Collaborator Author

oops, the pull request i just merged (1a36700 ) was #72 not 74

…ver.java.

Users can implement such behavior them self easily.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like here, we have to update these package names too!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xd yes

EDIT: fixed in 01d74a8

@TooTallNate

Copy link
Copy Markdown
Owner

Hey David. This all looks really nice. There's some rough edges we need to smooth out before we can merge. Just trying to run the ChatServer example with Chrome 17.0.963.56 (I'm assuming using Draft 17 or compatible) gets me this exception (on the server) when "Connect" is pressed:

☮ ~/Java-WebSocket (remotes/david/master) ⚡ java -cp build/examples:dist/WebSocket.jar ChatServer
ChatServer started on port: 8887
Exception in thread "Thread-1" java.lang.NullPointerException
    at org.java_websocket.WebSocket.handleRead(WebSocket.java:147)
    at org.java_websocket.WebSocketServer.run(WebSocketServer.java:195)
    at java.lang.Thread.run(Thread.java:680)

The same thing happens when trying to connect with the ChatClient example.

@Davidiusdadi

Copy link
Copy Markdown
Collaborator Author

a0a5f92 should fix the NullPointerException
cc859aa also fixes an error with the draft75 handshake

But we should not merge just yet.

@TooTallNate

Copy link
Copy Markdown
Owner

Build errors with the latest commits:


Buildfile: /Users/nrajlich/Java-WebSocket/build.xml

compile:
    [javac] Compiling 4 source files to /Users/nrajlich/Java-WebSocket/build/examples
    [javac] /Users/nrajlich/Java-WebSocket/example/AutobahnClientTest.java:6: cannot find symbol
    [javac] symbol  : class Draft
    [javac] location: package org.java_websocket
    [javac] import org.java_websocket.Draft;
    [javac]                          ^
    [javac] /Users/nrajlich/Java-WebSocket/example/AutobahnClientTest.java:7: cannot find symbol
    [javac] symbol  : class ServerHandshake
    [javac] location: package org.java_websocket
    [javac] import org.java_websocket.ServerHandshake;
    [javac]                          ^
    [javac] /Users/nrajlich/Java-WebSocket/example/AutobahnClientTest.java:14: cannot find symbol
    [javac] symbol  : class Draft
    [javac] location: class AutobahnClientTest
    [javac]     public AutobahnClientTest( Draft d , URI uri ) {
    [javac]                                ^
    [javac] /Users/nrajlich/Java-WebSocket/example/AutobahnClientTest.java:153: cannot find symbol
    [javac] symbol  : class ServerHandshake
    [javac] location: class AutobahnClientTest
    [javac]     public void onOpen( ServerHandshake handshake ) {
    [javac]                         ^
    [javac] /Users/nrajlich/Java-WebSocket/example/AutobahnServerTest.java:4: cannot find symbol
    [javac] symbol  : class ClientHandshake
    [javac] location: package org.java_websocket
    [javac] import org.java_websocket.ClientHandshake;
    [javac]                          ^
    [javac] /Users/nrajlich/Java-WebSocket/example/AutobahnServerTest.java:5: cannot find symbol
    [javac] symbol  : class Draft
    [javac] location: package org.java_websocket
    [javac] import org.java_websocket.Draft;
    [javac]                          ^
    [javac] /Users/nrajlich/Java-WebSocket/example/AutobahnServerTest.java:13: cannot find symbol
    [javac] symbol  : class Draft
    [javac] location: class AutobahnServerTest
    [javac]     public AutobahnServerTest( int port, Draft d ) throws UnknownHostException {
    [javac]                                          ^
    [javac] /Users/nrajlich/Java-WebSocket/example/AutobahnServerTest.java:17: cannot find symbol
    [javac] symbol  : class Draft
    [javac] location: class AutobahnServerTest
    [javac]     public AutobahnServerTest( InetSocketAddress address, Draft d ) {
    [javac]                                                           ^
    [javac] /Users/nrajlich/Java-WebSocket/example/AutobahnServerTest.java:22: cannot find symbol
    [javac] symbol  : class ClientHandshake
    [javac] location: class AutobahnServerTest
    [javac]     public void onOpen( WebSocket conn, ClientHandshake handshake ) {
    [javac]                                         ^
    [javac] /Users/nrajlich/Java-WebSocket/example/ChatClient.java:16: cannot find symbol
    [javac] symbol  : class Draft
    [javac] location: package org.java_websocket
    [javac] import org.java_websocket.Draft;
    [javac]                          ^
    [javac] /Users/nrajlich/Java-WebSocket/example/ChatClient.java:17: cannot find symbol
    [javac] symbol  : class ServerHandshake
    [javac] location: package org.java_websocket
    [javac] import org.java_websocket.ServerHandshake;
    [javac]                          ^
    [javac] /Users/nrajlich/Java-WebSocket/example/ChatServer.java:8: cannot find symbol
    [javac] symbol  : class ClientHandshake
    [javac] location: package org.java_websocket
    [javac] import org.java_websocket.ClientHandshake;
    [javac]                          ^
    [javac] /Users/nrajlich/Java-WebSocket/example/ChatServer.java:26: cannot find symbol
    [javac] symbol  : class ClientHandshake
    [javac] location: class ChatServer
    [javac]     public void onOpen( WebSocket conn, ClientHandshake handshake ) {
    [javac]                                         ^
    [javac] /Users/nrajlich/Java-WebSocket/example/AutobahnClientTest.java:34: cannot find symbol
    [javac] symbol  : class Draft
    [javac] location: class AutobahnClientTest
    [javac]             Draft d = new Draft_17();
    [javac]             ^
    [javac] /Users/nrajlich/Java-WebSocket/example/AutobahnClientTest.java:88: cannot find symbol
    [javac] symbol  : class Draft
    [javac] location: class AutobahnClientTest
    [javac]                             d = (Draft) Class.forName( "Draft_" + spl[ 1 ] ).getConstructor().newInstance();
    [javac]                                  ^
    [javac] /Users/nrajlich/Java-WebSocket/example/ChatClient.java:44: cannot find symbol
    [javac] symbol  : class Draft
    [javac] location: class ChatClient
    [javac]         Draft[] drafts = { new Draft_10(), new Draft_17(), new Draft_76(), new Draft_75() };
    [javac]         ^
    [javac] /Users/nrajlich/Java-WebSocket/example/ChatClient.java:105: cannot find symbol
    [javac] symbol  : class Draft
    [javac] location: class ChatClient
    [javac]                 cc = new WebSocketClient( new URI( uriField.getText() ), (Draft) draft.getSelectedItem() ) {
    [javac]                                                                           ^
    [javac] /Users/nrajlich/Java-WebSocket/example/ChatClient.java:114: cannot find symbol
    [javac] symbol: class ServerHandshake
    [javac]                     public void onOpen( ServerHandshake handshake ) {
    [javac]                                         ^
    [javac] 18 errors

BUILD FAILED
/Users/nrajlich/Java-WebSocket/build.xml:7: Compile failed; see the compiler error output for details.

Total time: 0 seconds

@Davidiusdadi

Copy link
Copy Markdown
Collaborator Author

xd my eclipse was out of sync with the file system

@Davidiusdadi Davidiusdadi mentioned this pull request Mar 5, 2012
@Davidiusdadi

Copy link
Copy Markdown
Collaborator Author

Ok i think this pull request can be merged now.
I briefly tested all drafts locally and did a full client and server autobahn test.
The current other issues are separate from this pull request.

TooTallNate added a commit that referenced this pull request Mar 5, 2012
Huge API overhaul. This is in preparation for a v1.0 release of Java-WebSocket :)
@TooTallNate
TooTallNate merged commit 9709afd into TooTallNate:master Mar 5, 2012
@TooTallNate

Copy link
Copy Markdown
Owner

Ok @Davidiusdadi beautiful :) merged

@detro

detro commented Mar 5, 2012

Copy link
Copy Markdown
Contributor

@TooTallNate @Davidiusdadi Guys, I'm pretty sure some API (that I read up you wanted to have in the release) got lost along the way.

@Davidiusdadi

Copy link
Copy Markdown
Collaborator Author

The fact that the server makes use of a queue at all is an implementation detail that might change over time.

It the future there may be multiple queues for several executors threads or data may be written directly in the send methods if necessary even though thats unlikely to happen.

However you can be sure that the data you send out will be send out via the socket as soon as possible.

I'd like know in which way you depend on this information.

@detro

detro commented Mar 5, 2012

Copy link
Copy Markdown
Contributor

It's part of the specs. No other reason :)

I'm just implementing what exactly the specs says: the sum of the data present in the buffer not yet sent.

If the implementation changes, of course this calculation will have to change.
But for now seems the simplest way to do this.

@TooTallNate

Copy link
Copy Markdown
Owner

I think @detro means http://dev.w3.org/html5/websockets/#dom-websocket-bufferedamount

And so 👍 from me.

@Davidiusdadi

Copy link
Copy Markdown
Collaborator Author

There are a lot of specs could you link it?

@detro

detro commented Mar 5, 2012

Copy link
Copy Markdown
Contributor

Lots?

There is the "work in progress / dev" one: http://dev.w3.org/html5/websockets/#dom-websocket-bufferedamount
And the "stable" one: http://www.w3.org/TR/websockets/#dom-websocket-bufferedamount

Both define "bufferedAmount" in exactly the same way (for now).

@detro

detro commented Mar 5, 2012

Copy link
Copy Markdown
Contributor

Btw, I catched up with your master and recommitted the bufferedAmount stuff: detro@58f939c

you could pick that one directly.

maakolk pushed a commit to maakolk/Java-WebSocket that referenced this pull request Mar 5, 2017
maakolk pushed a commit to maakolk/Java-WebSocket that referenced this pull request Mar 5, 2017
Huge API overhaul. This is in preparation for a v1.0 release of Java-WebSocket :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants