Luc14860 / jwebsocket

Automatically exported from code.google.com/p/jwebsocket
0 stars 0 forks source link

Not able to receive binary data with jWebSocket #197

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,
I am using jWebSocketFullSources-1.0-b30518 package and tried to receive the 
BINARY data from the server. But while processing the receeived packet from 
jWebSocket side I could see that it is not getting notified to upper layer due 
to the BINARY frametype. Please refer the following code snippet.

        private void processHybi() {
            WebSocketClientEvent lWSCE;
            WebSocketFrameType lFrameType;

            while (mIsRunning) {
                try {
                    WebSocketPacket lPacket = WebSocketProtocolAbstraction.protocolToRawPacket(mVersion, mIS);
                    lFrameType = (lPacket != null ? lPacket.getFrameType() : WebSocketFrameType.INVALID);
                    if (null == lFrameType) {
                        if (mIsRunning) {
                            System.out.println("processHybi: FRAME TYPE IS NULL: Connection broken..\n");
                            setCloseReason("Connection broken");
                        } else {
                            System.out.println("processHybi: FRAME TYPE IS NULL: Connection terminated..\n");
                            setCloseReason("Client terminated");
                        }
                        mIsRunning = false;
                    } else if (WebSocketFrameType.INVALID == lFrameType) {
                        System.out.println("processHybi: FRAME TYPE IS INVALID...\n");
                        mIsRunning = false;
                        setCloseReason("Invalid hybi frame type detected");
                    } else if (WebSocketFrameType.CLOSE == lFrameType) {
                        mIsRunning = false;
                        System.out.println("processHybi: Server closed connection...\n");
                        setCloseReason("Server closed connection");
                    } else if (WebSocketFrameType.PING == lFrameType) {
                        System.out.println("processHybi: FRAME TYPE IS PING...\n");
                        WebSocketPacket lPong = new RawPacket(
                                WebSocketFrameType.PONG, "");
                        send(lPong);
                    } else if (WebSocketFrameType.PONG == lFrameType) {
                        System.out.println("processHybi: FRAME TYPE IS PONG...\n");
                        // TODO: need to process connection management here!
                    } else if (WebSocketFrameType.TEXT == lFrameType) {
                        System.out.println("processHybi: FRAME TYPE IS TEXT...\n");
                        lWSCE = new WebSocketTokenClientEvent(mClient, null, null);
                        notifyPacket(lWSCE, lPacket);
                    }
                } catch (Exception lEx) {
                    mIsRunning = false;
                    setCloseReason(lEx.getClass().getName() + " in hybi processor: " + lEx.getMessage());
                }
            }
        }

        private void sendPing() {
            SendPing lSendPing = new SendPing();
            lSendPing.start();
        }

In above function there is no handling for BINARY data. I would like to know 
how binary data receive is supported in jWebSocket. Please help.

Thanks and Regards
Dhanesh

Original issue reported on code.google.com by dhanesh....@gmail.com on 26 Jun 2013 at 11:18