What Connection is this?

♀尐吖头ヾ 提交于 2019-12-12 05:17:56

问题


So I'm following tutorial of Face detection using HTML5, javascript, webrtc, websockets, Jetty and OpenCV. Not exactly like that, but more or less like that (Like, I don't use the face detection thingy). I use Eclipse to implement it.

There's these parts (I simplified it)

private Connection connection;

public void onOpen(Connection connection) {
        this.connection = connection;
        this.connection.setMaxBinaryMessageSize(1024 * 512);
    }

public void onMessage(byte[] data, int offset, int length) {
    try {
        this.connection.sendMessage(data, 0, data.length);
    } catch (IOException e) { }
}

and the specific line that's confusing me is

this.connection.sendMessage(result, 0, result.length);

what is the Connection that's being used here? When I use Ctrl+Shift+O of Eclipse, from the lib I had, Eclipse offer these

  1. org.eclipse.jetty.io.Connection
  2. org.eclipse.jetty.client.api.Connection
  3. java.sql.Connection

but none of the Connection it gave have that sendMessage method. I've tried searching the net, but the tutorials I've found that used the same line, also didn't tell anything about it.

What is that Connection? Is there from any lib I haven't had yet?

And there's this javadoc page of that seems to explain this class, and it does have the same method with same params, but I still don't understand. Seems that it comes with Jetty, but which jar? I used Jetty 9.x though...

Thank you very much.


回答1:


It might be from the org.eclipse.jetty.websocket.WebSocket package.

You can find the JAR here: http://mvnrepository.com/artifact/org.eclipse.jetty/jetty-websocket/8.1.0.RC5



来源:https://stackoverflow.com/questions/23557300/what-connection-is-this

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!