openvidu-java-client : change to lambda function

pull/821/head
최종명 2023-10-16 17:57:22 +09:00
parent a14f8d997d
commit b24d89c884
1 changed files with 108 additions and 129 deletions

View File

@ -123,9 +123,7 @@ public class Session {
this.getSessionId(); this.getSessionId();
} }
final HttpClientResponseHandler<String> responseHandler = new HttpClientResponseHandler<String>() { final HttpClientResponseHandler<String> responseHandler = response -> {
@Override
public String handleResponse(final ClassicHttpResponse response) throws IOException, HttpException {
final int status = response.getCode(); final int status = response.getCode();
if (status == HttpStatus.SC_OK) { if (status == HttpStatus.SC_OK) {
String token = OpenVidu.httpResponseEntityToJson(response.getEntity()).get("id").getAsString(); String token = OpenVidu.httpResponseEntityToJson(response.getEntity()).get("id").getAsString();
@ -134,7 +132,6 @@ public class Session {
} else { } else {
throw OpenVidu.openViduHttpException(status); throw OpenVidu.openViduHttpException(status);
} }
}
}; };
JsonObject json = tokenOptions.toJsonObject(sessionId); JsonObject json = tokenOptions.toJsonObject(sessionId);
@ -224,9 +221,7 @@ public class Session {
*/ */
public void close() throws OpenViduJavaClientException, OpenViduHttpException { public void close() throws OpenViduJavaClientException, OpenViduHttpException {
final HttpClientResponseHandler<Void> responseHandler = new HttpClientResponseHandler<Void>() { final HttpClientResponseHandler<Void> responseHandler = response -> {
@Override
public Void handleResponse(final ClassicHttpResponse response) throws IOException, HttpException {
final int status = response.getCode(); final int status = response.getCode();
if (status == HttpStatus.SC_NO_CONTENT) { if (status == HttpStatus.SC_NO_CONTENT) {
openVidu.activeSessions.remove(sessionId); openVidu.activeSessions.remove(sessionId);
@ -235,7 +230,6 @@ public class Session {
throw OpenVidu.openViduHttpException(status); throw OpenVidu.openViduHttpException(status);
} }
return null; return null;
}
}; };
HttpDelete request = new HttpDelete(this.openVidu.hostname + OpenVidu.API_SESSIONS + "/" + this.sessionId); HttpDelete request = new HttpDelete(this.openVidu.hostname + OpenVidu.API_SESSIONS + "/" + this.sessionId);
@ -272,9 +266,7 @@ public class Session {
final String beforeJSON = this.toJson(); final String beforeJSON = this.toJson();
final HttpClientResponseHandler<Boolean> responseHandler = new HttpClientResponseHandler<Boolean>() { final HttpClientResponseHandler<Boolean> responseHandler = response -> {
@Override
public Boolean handleResponse(final ClassicHttpResponse response) throws IOException, HttpException {
final int status = response.getCode(); final int status = response.getCode();
if (status == HttpStatus.SC_OK) { if (status == HttpStatus.SC_OK) {
resetWithJson(OpenVidu.httpResponseEntityToJson(response.getEntity())); resetWithJson(OpenVidu.httpResponseEntityToJson(response.getEntity()));
@ -285,7 +277,6 @@ public class Session {
} else { } else {
throw OpenVidu.openViduHttpException(status); throw OpenVidu.openViduHttpException(status);
} }
}
}; };
HttpGet request = new HttpGet( HttpGet request = new HttpGet(
@ -344,9 +335,7 @@ public class Session {
*/ */
public void forceDisconnect(String connectionId) throws OpenViduJavaClientException, OpenViduHttpException { public void forceDisconnect(String connectionId) throws OpenViduJavaClientException, OpenViduHttpException {
final HttpClientResponseHandler<Void> responseHandler = new HttpClientResponseHandler<Void>() { final HttpClientResponseHandler<Void> responseHandler = response -> {
@Override
public Void handleResponse(final ClassicHttpResponse response) throws IOException, HttpException {
final int status = response.getCode(); final int status = response.getCode();
if (status == HttpStatus.SC_NO_CONTENT) { if (status == HttpStatus.SC_NO_CONTENT) {
// Remove connection from activeConnections map // Remove connection from activeConnections map
@ -371,7 +360,6 @@ public class Session {
throw OpenVidu.openViduHttpException(status); throw OpenVidu.openViduHttpException(status);
} }
return null; return null;
}
}; };
HttpDelete request = new HttpDelete( HttpDelete request = new HttpDelete(
@ -427,9 +415,7 @@ public class Session {
*/ */
public void forceUnpublish(String streamId) throws OpenViduJavaClientException, OpenViduHttpException { public void forceUnpublish(String streamId) throws OpenViduJavaClientException, OpenViduHttpException {
final HttpClientResponseHandler<Void> responseHandler = new HttpClientResponseHandler<Void>() { final HttpClientResponseHandler<Void> responseHandler = response -> {
@Override
public Void handleResponse(final ClassicHttpResponse response) throws IOException, HttpException {
final int status = response.getCode(); final int status = response.getCode();
if (status == HttpStatus.SC_NO_CONTENT) { if (status == HttpStatus.SC_NO_CONTENT) {
for (Connection connection : connections.values()) { for (Connection connection : connections.values()) {
@ -445,7 +431,6 @@ public class Session {
throw OpenVidu.openViduHttpException(status); throw OpenVidu.openViduHttpException(status);
} }
return null; return null;
}
}; };
HttpDelete request = new HttpDelete( HttpDelete request = new HttpDelete(
@ -499,9 +484,7 @@ public class Session {
public Connection updateConnection(String connectionId, ConnectionProperties connectionProperties) public Connection updateConnection(String connectionId, ConnectionProperties connectionProperties)
throws OpenViduJavaClientException, OpenViduHttpException { throws OpenViduJavaClientException, OpenViduHttpException {
final HttpClientResponseHandler<Connection> responseHandler = new HttpClientResponseHandler<Connection>() { final HttpClientResponseHandler<Connection> responseHandler = response -> {
@Override
public Connection handleResponse(final ClassicHttpResponse response) throws IOException, HttpException {
final int status = response.getCode(); final int status = response.getCode();
if (status == HttpStatus.SC_OK) { if (status == HttpStatus.SC_OK) {
log.info("Connection {} updated", connectionId); log.info("Connection {} updated", connectionId);
@ -525,7 +508,6 @@ public class Session {
existingConnection.overrideConnectionProperties(connectionProperties); existingConnection.overrideConnectionProperties(connectionProperties);
return existingConnection; return existingConnection;
} }
}
}; };
JsonObject json = connectionProperties.toJson(this.sessionId); JsonObject json = connectionProperties.toJson(this.sessionId);
@ -657,9 +639,7 @@ public class Session {
return; return;
} }
final HttpClientResponseHandler<Void> responseHandler = new HttpClientResponseHandler<Void>() { final HttpClientResponseHandler<Void> responseHandler = response -> {
@Override
public Void handleResponse(final ClassicHttpResponse response) throws IOException, HttpException {
final int status = response.getCode(); final int status = response.getCode();
if (status == HttpStatus.SC_OK) { if (status == HttpStatus.SC_OK) {
JsonObject responseJson = OpenVidu.httpResponseEntityToJson(response.getEntity()); JsonObject responseJson = OpenVidu.httpResponseEntityToJson(response.getEntity());
@ -692,7 +672,6 @@ public class Session {
throw OpenVidu.openViduHttpException(status); throw OpenVidu.openViduHttpException(status);
} }
return null; return null;
}
}; };
JsonObject json = properties.toJson(); JsonObject json = properties.toJson();