问题
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
org.eclipse.jetty.io.Connection
org.eclipse.jetty.client.api.Connection
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