Skip to content

Commit

Permalink
Fix Websocket Response not displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
wanghongenpin committed Sep 15, 2024
1 parent a422131 commit a6078e5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/network/channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,9 @@ class ChannelPipeline extends ChannelHandler<Uint8List> {
//websocket协议
if (data is HttpResponse && data.isWebSocket && remoteChannel != null) {
data.request?.response = data;
channelContext.host = channelContext.host?.copyWith(scheme: channel.isSsl ? HostAndPort.wssScheme : HostAndPort.wsScheme);
channelContext.currentRequest?.hostAndPort = channelContext.host;

channelContext.currentRequest?.hostAndPort?.scheme =
channel.isSsl ? HostAndPort.wssScheme : HostAndPort.wsScheme;
logger.d("webSocket ${data.request?.hostAndPort}");
remoteChannel.write(data);

Expand Down
4 changes: 4 additions & 0 deletions lib/network/host_port.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class HostAndPort {
return '$scheme$host${(port == 80 || port == 443) ? "" : ":$port"}';
}

HostAndPort copyWith({String? scheme, String? host, int? port}) {
return HostAndPort(scheme ?? this.scheme, host ?? this.host, port ?? this.port);
}

@override
bool operator ==(Object other) =>
identical(this, other) ||
Expand Down
5 changes: 2 additions & 3 deletions lib/ui/mobile/request/domians.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ class DomainListState extends State<DomainList> with AutomaticKeepAliveClientMix
}

addResponse(HttpResponse response) {
var hostAndPort = response.request!.hostAndPort;
if (response.isWebSocket && containerMap[hostAndPort]?.contains(response.request) == false) {
HostAndPort? hostAndPort = response.request!.hostAndPort;
if (response.isWebSocket) {
add(response.request!);
}

Expand Down Expand Up @@ -202,7 +202,6 @@ class DomainListState extends State<DomainList> with AutomaticKeepAliveClientMix
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) {
showHostAndPort = view.elementAt(index);
print(containerMap.keys);
return Scaffold(
appBar: AppBar(title: Text(view.elementAt(index).domain, style: const TextStyle(fontSize: 16))),
body: RequestSequence(
Expand Down

0 comments on commit a6078e5

Please sign in to comment.