Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WebSocketClient #4972

Merged
merged 31 commits into from
Aug 22, 2023
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
00e9d6d
[WIP] Add WebSocketClient
minwoox May 26, 2023
d1b2fa9
WIP
minwoox Jun 27, 2023
9299aa9
Redesign API
minwoox Jun 29, 2023
2727bba
Merge branch 'main' into WebSocketClient
minwoox Jun 29, 2023
d832e8b
Add more tests
minwoox Jun 30, 2023
dddfeeb
Add Javadoc
minwoox Jun 30, 2023
bb6975a
Add requiresNewConnection
minwoox Jul 4, 2023
eddb125
Add WebSocketSession.abort()
minwoox Jul 4, 2023
9301b1c
Address comments from @ikhoon and @trustin
minwoox Jul 7, 2023
223b86a
Address more
minwoox Jul 10, 2023
35ade23
Fix
minwoox Jul 10, 2023
a94f576
Add WebSocketHttp1ResponseWrapper
minwoox Jul 11, 2023
075db60
Merge branch 'main' into WebSocketClient
minwoox Jul 25, 2023
a0cc9a5
Merge branch 'main' into WebSocketClient
minwoox Jul 25, 2023
4a21b49
Parially address comments from @ikhoon
minwoox Aug 10, 2023
7b63523
Merge branch 'main' into WebSocketClient
minwoox Aug 10, 2023
63f625c
Parially address comments from @jrhee17
minwoox Aug 10, 2023
d180dfd
Use WebSocketHttp1ClientChannelHandler instead of Http1ResponseDecoder
minwoox Aug 14, 2023
1dcb57c
Fix
minwoox Aug 14, 2023
86fcf40
Fix test
minwoox Aug 14, 2023
4fdefc8
Add unstable api
minwoox Aug 14, 2023
529961c
Remove unused method
minwoox Aug 16, 2023
cefafba
Merge branch 'main' into WebSocketClient
minwoox Aug 16, 2023
e0b1f98
Address comments from @trustin
minwoox Aug 21, 2023
2c690e8
Merge branch 'main' into WebSocketClient
minwoox Aug 21, 2023
81b3670
Add comment
minwoox Aug 21, 2023
9b6ff8b
Fix lint
minwoox Aug 21, 2023
9a5ff19
Add breaks
minwoox Aug 21, 2023
51a3a3c
Address comments from @ikhoon
minwoox Aug 21, 2023
0e8f1bf
Abort Publisher
minwoox Aug 21, 2023
ec847a4
Fix flaky
minwoox Aug 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add WebSocketSession.abort()
  • Loading branch information
minwoox committed Jul 4, 2023
commit eddb1253e623e4284268e48ab55752184c86a5eb
Original file line number Diff line number Diff line change
@@ -24,9 +24,11 @@
import com.linecorp.armeria.common.HttpHeaderNames;
import com.linecorp.armeria.common.ResponseHeaders;
import com.linecorp.armeria.common.annotation.Nullable;
import com.linecorp.armeria.common.stream.AbortedStreamException;
import com.linecorp.armeria.common.stream.StreamMessage;
import com.linecorp.armeria.common.websocket.WebSocket;
import com.linecorp.armeria.common.websocket.WebSocketFrame;
import com.linecorp.armeria.common.websocket.WebSocketWriter;
import com.linecorp.armeria.internal.common.websocket.WebSocketFrameEncoder;

/**
@@ -93,4 +95,22 @@ public boolean send(WebSocket outbound) {
outbound.map(webSocketFrame -> HttpData.wrap(encoder.encode(ctx, webSocketFrame)));
return outboundFuture.complete(streamMessage);
}

/**
* Aborts this {@link WebSocketSession}.
*/
public void abort() {
abort(AbortedStreamException.get());
}

/**
* Aborts this {@link WebSocketSession} with the specified {@link Throwable}.
*/
public void abort(Throwable cause) {
requireNonNull(cause, "cause");
final WebSocketWriter outbound = WebSocket.streaming();
outbound.abort(cause);
send(outbound);
inbound().abort(cause);
}
}
Original file line number Diff line number Diff line change
@@ -27,8 +27,6 @@
import com.linecorp.armeria.common.SerializationFormat;
import com.linecorp.armeria.common.SessionProtocol;
import com.linecorp.armeria.common.annotation.Nullable;
import com.linecorp.armeria.common.websocket.WebSocket;
import com.linecorp.armeria.common.websocket.WebSocketWriter;
import com.linecorp.armeria.server.ServerBuilder;
import com.linecorp.armeria.server.websocket.WebSocketService;
import com.linecorp.armeria.testing.junit5.server.ServerExtension;
@@ -65,13 +63,6 @@ void subprotocol(SessionProtocol sessionProtocol,
assertThat(session.responseHeaders().get(HttpHeaderNames.SEC_WEBSOCKET_PROTOCOL))
.isEqualTo(selected);
}
close(session);
}

private static void close(WebSocketSession session) {
final WebSocketWriter outbound = WebSocket.streaming();
outbound.close();
session.send(outbound);
session.inbound().abort();
session.abort();
}
}