Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Using org.eclipse.jetty.util.ajax.JSON in custom WebSocketListener

Good evening,

I have 2 questions related to JSON usage please:

1) I have added jetty-util-ajax Maven-package to
https://github.com/afarber/jetty-newbie/blob/master/EmbWebsocketListener/pom.xml 

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-util-ajax</artifactId>
            <version>9.3.9.v20160517</version>
        </dependency>

But for some reason still can not use

         import org.eclipse.jetty.util.ajax.JSON;

in Java-files. Is that class for public use or should I better use Gson?

2) In my custom WebsocketListener implementation at
https://github.com/afarber/jetty-newbie/blob/master/EmbWebsocketListener/src/main/java/org/eclipse/jetty/demo/listener/MyListener.java

I plan to close connection on all binary messages with

    @Override
    public void onWebSocketBinary(byte[] arg0, int arg1, int arg2) {
        mSession.close(1003, null);
    }

and all text messages should be parsable JSON
(or I'd like to close connection too).

Is it possible to register such a "policy" at 
in a servlet-example, but can't find it anymore...)
or should I enforce this manually in onWebSocketText?

Thank you
Alex





Back to the top