TooTallNate / Java-WebSocket

A barebones WebSocket client and server implementation written in 100% Java.
http://tootallnate.github.io/Java-WebSocket
MIT License
10.53k stars 2.58k forks source link

How WebSocketServer instance can send a metadata to a WebSocketClient instance onOpen ? #1409

Closed greg771377 closed 6 months ago

greg771377 commented 6 months ago

Hi,

I want that when a WebSocketClient connects the WebSocketServer that it gets a "myMetadataValue" from the WebSocketServer instance.

I thought I could put a HTTP-Header on server in the onOpen method to send to client. But I don't see how ?...

Then on client I would retrieve it in the onOpen method like this :

    public void onOpen(ServerHandshake handshakedata) {
        String myMetadataValue= handshakedata.getFieldValue("myMetadataValue");

Is it possible to do that ? How can I do that ?

Thank you, Gregory