Skip to content

Commit

Permalink
Sit spot, sit.
Browse files Browse the repository at this point in the history
  • Loading branch information
niloc132 committed Jun 29, 2022
1 parent 5923142 commit 6d4456e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
@ServerEndpoint(value = "/grpc-websocket", subprotocols = "grpc-websockets-multiplex")
public class MultiplexedWebSocketServerStream {
private static final Logger logger = Logger.getLogger(MultiplexedWebSocketServerStream.class.getName());
public static final Metadata.Key<String> PATH = Metadata.Key.of("grpc-websockets-path", Metadata.ASCII_STRING_MARSHALLER);
public static final Metadata.Key<String> PATH =
Metadata.Key.of("grpc-websockets-path", Metadata.ASCII_STRING_MARSHALLER);

private final ServerTransportListener transportListener;
private final List<? extends ServerStreamTracer.Factory> streamTracerFactories;
Expand Down Expand Up @@ -95,7 +96,8 @@ public void onMessage(String message) {

@OnMessage
public void onMessage(ByteBuffer message) throws IOException {
// Each message starts with an int, to indicate stream id. If that int is negative, the other end has performed a half close (and this is the final message).
// Each message starts with an int, to indicate stream id. If that int is negative, the other end has performed
// a half close (and this is the final message).
int streamId = message.getInt();
final boolean closed;
if (streamId < 0) {
Expand All @@ -120,9 +122,10 @@ public void onMessage(ByteBuffer message) throws IOException {
processHeaders(message, streamId);
return;
}
// if (stream == null) {
// websocketSession.close(new CloseReason(CloseReason.CloseCodes.PROTOCOL_ERROR, "No stream with that ID: " + streamId));
// }
// if (stream == null) {
// websocketSession.close(new CloseReason(CloseReason.CloseCodes.PROTOCOL_ERROR, "No stream with that ID: " +
// streamId));
// }

// For every message after headers, the next byte is control flow
byte controlFlow = message.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ public JettyBackedGrpcServer(
// Set up websocket for grpc-web
if (config.websockets()) {
JakartaWebSocketServletContainerInitializer.configure(context, (servletContext, container) -> {
// container.addEndpoint(
// ServerEndpointConfig.Builder.create(WebSocketServerStream.class, "/{service}/{method}")
// .configurator(new ServerEndpointConfig.Configurator() {
// @Override
// public <T> T getEndpointInstance(Class<T> endpointClass)
// throws InstantiationException {
// return (T) filter.create(WebSocketServerStream::new);
// }
// })
// .build());
// container.addEndpoint(
// ServerEndpointConfig.Builder.create(WebSocketServerStream.class, "/{service}/{method}")
// .configurator(new ServerEndpointConfig.Configurator() {
// @Override
// public <T> T getEndpointInstance(Class<T> endpointClass)
// throws InstantiationException {
// return (T) filter.create(WebSocketServerStream::new);
// }
// })
// .build());
container.addEndpoint(
ServerEndpointConfig.Builder.create(MultiplexedWebSocketServerStream.class, "/grpc-websocket")
.configurator(new ServerEndpointConfig.Configurator() {
Expand Down

0 comments on commit 6d4456e

Please sign in to comment.