Skip to content

WebSocketClient uses wsfactory in the constructor before setting is possible (regression) #208

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

Closed
Joris-van-der-Wel opened this issue Sep 18, 2013 · 3 comments

Comments

@Joris-van-der-Wel
Copy link

WebSocketClient uses wsfactory in its constructor (https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/java/org/java_websocket/client/WebSocketClient.java#L109), however an instance of WebSocketClientFactory can not be passed in the constructor.
There is only a setter called setWebSocketFactory (https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/java/org/java_websocket/client/WebSocketClient.java#L389), which can of course only be called after the constructor has run.
This causes WebSocketClient to always use the default constructor (https://github.com/TooTallNate/Java-WebSocket/blob/master/src/main/java/org/java_websocket/client/WebSocketClient.java#L72)

I am not sure what the best solution would be. Break the API again and add WebSocketClientFactory to the constructor and remove setWebSocketFactory? (which is what I am doing temporarily).

Or defer the calls to the factory until after the constructor somehow?

Thanks.

@Davidiusdadi
Copy link
Collaborator

hey check out #205

The WebSocketClientFactory will then not be necessary any more.
If you want to do wss check out:
Davidiusdadi@9b0a4b8#L1L82

@Joris-van-der-Wel
Copy link
Author

Ah, I was using it to add some meta data to each WebSocket (by extending WebSocketImpl) for both client and server. This was easier to implement than a WeakHashMap, and the usage of abstract factories is in my opinion cleaner.

I would prefer not to lose abstract factories, but I can use a WeakHashMap if needed (the performance difference would be probably be minor in my case).

I would also be helped by a simple empty Object reference I can use to store stuff in, but that might be considered less clean.

@marci4
Copy link
Collaborator

marci4 commented May 11, 2017

Issue should be already solved.

Greetings
Marci4

@marci4 marci4 closed this as completed May 11, 2017
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

No branches or pull requests

3 participants