Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 18 additions & 4 deletions Lookin.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@
D4224EEF2358ED3400ED9626 /* LKMeasureController.m in Sources */ = {isa = PBXBuildFile; fileRef = D4224EEE2358ED3400ED9626 /* LKMeasureController.m */; };
D4D1B2D32353975A002A5071 /* LKWindowToolbarScaleView.m in Sources */ = {isa = PBXBuildFile; fileRef = D4D1B2D22353975A002A5071 /* LKWindowToolbarScaleView.m */; };
D4E1FD66236169130070DFB8 /* LKMeasureResultLineData.m in Sources */ = {isa = PBXBuildFile; fileRef = D4E1FD65236169130070DFB8 /* LKMeasureResultLineData.m */; };
F7C2F32F2B02222C003AD0E7 /* LKMenuPopoverWirelessDevicesListController.m in Sources */ = {isa = PBXBuildFile; fileRef = F7C2F32E2B02222C003AD0E7 /* LKMenuPopoverWirelessDevicesListController.m */; };
F7C2F3322B02348F003AD0E7 /* LKLaunchWirelessDeviceView.m in Sources */ = {isa = PBXBuildFile; fileRef = F7C2F3312B02348F003AD0E7 /* LKLaunchWirelessDeviceView.m */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -567,6 +569,10 @@
D4E1FD64236169130070DFB8 /* LKMeasureResultLineData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LKMeasureResultLineData.h; sourceTree = "<group>"; };
D4E1FD65236169130070DFB8 /* LKMeasureResultLineData.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LKMeasureResultLineData.m; sourceTree = "<group>"; };
D97552B9BF9170E090F8CAA7 /* Pods-LookinClient.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LookinClient.debug.xcconfig"; path = "Target Support Files/Pods-LookinClient/Pods-LookinClient.debug.xcconfig"; sourceTree = "<group>"; };
F7C2F32D2B02222C003AD0E7 /* LKMenuPopoverWirelessDevicesListController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LKMenuPopoverWirelessDevicesListController.h; sourceTree = "<group>"; };
F7C2F32E2B02222C003AD0E7 /* LKMenuPopoverWirelessDevicesListController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LKMenuPopoverWirelessDevicesListController.m; sourceTree = "<group>"; };
F7C2F3302B02348F003AD0E7 /* LKLaunchWirelessDeviceView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LKLaunchWirelessDeviceView.h; sourceTree = "<group>"; };
F7C2F3312B02348F003AD0E7 /* LKLaunchWirelessDeviceView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LKLaunchWirelessDeviceView.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -920,10 +926,10 @@
children = (
AAA8C08B21CC17670017A345 /* LKAppsManager.m */,
AAA8C08821CC17670017A345 /* LKAppsManager.h */,
AAA8C08921CC17670017A345 /* LKConnectionManager.h */,
AAA8C08C21CC17670017A345 /* LKConnectionManager.m */,
AA7F157622C0F2B9004436AD /* LKConnectionRequest.h */,
AA7F157722C0F2B9004436AD /* LKConnectionRequest.m */,
AAA8C08921CC17670017A345 /* LKConnectionManager.h */,
AAA8C08D21CC17670017A345 /* LKInspectableApp.h */,
AAA8C08A21CC17670017A345 /* LKInspectableApp.m */,
);
Expand Down Expand Up @@ -1078,10 +1084,12 @@
D4D1B2D22353975A002A5071 /* LKWindowToolbarScaleView.m */,
A2C71CBC282165DB0056D991 /* LKWindowToolbarAppButton.h */,
A2C71CBD282165DB0056D991 /* LKWindowToolbarAppButton.m */,
AAA8C10521CC17680017A345 /* LKMenuPopoverAppsListController.h */,
AAA8C0F821CC17680017A345 /* LKMenuPopoverAppsListController.m */,
AA049A1521E61B85008C6366 /* LKMenuPopoverSettingController.h */,
AA049A1621E61B85008C6366 /* LKMenuPopoverSettingController.m */,
AAA8C10521CC17680017A345 /* LKMenuPopoverAppsListController.h */,
F7C2F32D2B02222C003AD0E7 /* LKMenuPopoverWirelessDevicesListController.h */,
F7C2F32E2B02222C003AD0E7 /* LKMenuPopoverWirelessDevicesListController.m */,
);
path = Toolbar;
sourceTree = "<group>";
Expand All @@ -1106,10 +1114,12 @@
AAA8C11421CC17680017A345 /* Launch */ = {
isa = PBXGroup;
children = (
AAA8C11821CC17680017A345 /* LKLaunchAppView.m */,
AAA8C11521CC17680017A345 /* LKLaunchAppView.h */,
AAA8C11621CC17680017A345 /* LKLaunchViewController.m */,
AAA8C11821CC17680017A345 /* LKLaunchAppView.m */,
F7C2F3302B02348F003AD0E7 /* LKLaunchWirelessDeviceView.h */,
F7C2F3312B02348F003AD0E7 /* LKLaunchWirelessDeviceView.m */,
AAA8C11921CC17680017A345 /* LKLaunchViewController.h */,
AAA8C11621CC17680017A345 /* LKLaunchViewController.m */,
AAA8C11721CC17680017A345 /* LKLaunchWindowController.h */,
AAA8C11A21CC17680017A345 /* LKLaunchWindowController.m */,
);
Expand Down Expand Up @@ -1421,6 +1431,7 @@
AAE61CCE22A5063F00B3FB9F /* LKInputSearchSuggestionsRowView.m in Sources */,
A74C63072B540FDD0068FBB8 /* CwlDemangle.swift in Sources */,
AAA8C12621CC17680017A345 /* LKProgressIndicatorView.m in Sources */,
F7C2F32F2B02222C003AD0E7 /* LKMenuPopoverWirelessDevicesListController.m in Sources */,
A74C63122B5429B60068FBB8 /* LookinAutoLayoutConstraint+LookinClient.m in Sources */,
AAA8C12A21CC17680017A345 /* LKBaseControl.m in Sources */,
AACBACAF22AE983F00A8F89D /* LKDashboardAttributeRectView.m in Sources */,
Expand All @@ -1435,6 +1446,7 @@
A78FCEB42B334D3300F1D307 /* LKDanceUIAttrMaker.m in Sources */,
AAB65C092320FC30001E4299 /* LKDashboardSearchCardView.m in Sources */,
AA290358229824A400073B65 /* LKPanelContentView.m in Sources */,
F7C2F3322B02348F003AD0E7 /* LKLaunchWirelessDeviceView.m in Sources */,
A74C630F2B54202E0068FBB8 /* LookinObject+LookinClient.m in Sources */,
AAA8C15E21CC17680017A345 /* LKLaunchViewController.m in Sources */,
AA7F157822C0F2B9004436AD /* LKConnectionRequest.m in Sources */,
Expand Down Expand Up @@ -1643,6 +1655,7 @@
"$(inherited)",
"COCOAPODS=1",
"SHOULD_COMPILE_LOOKIN_SERVER=1",
"LOOKIN_SERVER_WIRELESS=1",
);
INFOPLIST_FILE = LookinClient/LookinClient_Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down Expand Up @@ -1684,6 +1697,7 @@
"$(inherited)",
"COCOAPODS=1",
"SHOULD_COMPILE_LOOKIN_SERVER=1",
"LOOKIN_SERVER_WIRELESS=1",
);
INFOPLIST_FILE = LookinClient/LookinClient_Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down
4 changes: 3 additions & 1 deletion LookinCLI/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ done
SHARED_SOURCES=()
while IFS= read -r source_file; do
SHARED_SOURCES+=("${source_file}")
done < <(find "${LOOKIN_SHARED_DIR}/Src/Main/Shared" "${LOOKIN_SHARED_DIR}/Src/Base" -name '*.m' | sort)
done < <(find "${LOOKIN_SHARED_DIR}/Src/Main/Shared" "${LOOKIN_SHARED_DIR}/Src/Base" \
-path "${LOOKIN_SHARED_DIR}/Src/Main/Shared/Channel" -prune -o \
-name '*.m' -print | sort)

xcrun --sdk macosx clang \
"${ARCH_FLAGS[@]}" \
Expand Down
10 changes: 5 additions & 5 deletions LookinClient/Connection/LKAppsManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ - (instancetype)init {
_didAutoReconnectSucc = [RACSubject subject];

@weakify(self);
[[[[LKConnectionManager sharedInstance].channelWillEnd filter:^BOOL(Lookin_PTChannel *channel) {
[[[[LKConnectionManager sharedInstance].channelWillEnd filter:^BOOL(id<LookinChannelProtocol> channel) {
@strongify(self);
return channel == self.inspectingApp.channel;

}] flattenMap:^__kindof RACSignal * _Nullable(Lookin_PTChannel *channel) {
}] flattenMap:^__kindof RACSignal * _Nullable(id<LookinChannelProtocol> channel) {
@strongify(self);

NSLog(@"current connection end");
Expand Down Expand Up @@ -120,13 +120,13 @@ - (RACSignal *)fetchAppInfosWithImage:(BOOL)needImages localInfos:(NSArray<Looki
}] ? : @[];
NSDictionary *params = @{@"needImages":@(needImages), @"local":localInfoIdentifiers};

return [[[[LKConnectionManager sharedInstance] tryToConnectAllPorts] flattenMap:^__kindof RACSignal * _Nullable(NSArray<Lookin_PTChannel *> *connectedChannels) {
return [[[[LKConnectionManager sharedInstance] tryToConnectAllPorts] flattenMap:^__kindof RACSignal * _Nullable(NSArray<id<LookinChannelProtocol>> *connectedChannels) {
if (!connectedChannels.count) {
// 没有任何 channel
return [RACSignal return:nil];
}

NSArray<RACSignal *> *signals = [connectedChannels lookin_map:^id(NSUInteger idx, Lookin_PTChannel *channel) {
NSArray<RACSignal *> *signals = [connectedChannels lookin_map:^id(NSUInteger idx, id<LookinChannelProtocol> channel) {
return [[[LKConnectionManager sharedInstance] requestWithType:LookinRequestTypeApp data:params channel:channel] catch:^RACSignal * _Nonnull(NSError * _Nonnull error) {
if (error.code == LookinErrCode_ServerVersionTooHigh || error.code == LookinErrCode_ServerVersionTooLow) {
// 这些 Lookin 版本不匹配的错误应该被保留,因为业务需要显示这些错误
Expand Down Expand Up @@ -154,7 +154,7 @@ - (RACSignal *)fetchAppInfosWithImage:(BOOL)needImages localInfos:(NSArray<Looki
}

if ([value isKindOfClass:[RACTuple class]]) {
RACTupleUnpack(LookinConnectionResponseAttachment *response, Lookin_PTChannel *relatedChannel) = value;
RACTupleUnpack(LookinConnectionResponseAttachment *response, id<LookinChannelProtocol> relatedChannel) = value;
if (response.error) {
NSAssert(NO, @"");
return nil;
Expand Down
42 changes: 37 additions & 5 deletions LookinClient/Connection/LKConnectionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@
//

#import <Foundation/Foundation.h>
#import "ECOChannelManager.h"
#import "Lookin_PTChannel.h"

@class Lookin_PTChannel;
@class LKConnectionRequest;

@protocol LookinChannelProtocol <NSObject>

@property (readonly) BOOL isConnected;

@property(nonatomic, strong) NSMutableSet<LKConnectionRequest *> *activeRequests;

@end

/**
iOS 是 Server 端,macOS 是 Client 端
Expand All @@ -28,16 +38,24 @@
/// 该方法不会 sendError
- (RACSignal *)tryToConnectAllPorts;

/// 返回的 data 为 RACTuple<LookinConnectionResponseAttachment *, Lookin_PTChannel *>
/// 返回的 data 为 RACTuple<LookinConnectionResponseAttachment *, id<LookinChannelProtocol>>
/// 在调用该方法发请求时,如果已有相同 type 的旧 request 尚未返回结果,则之前的旧 request 会被报告 Error,然后被丢弃
- (RACSignal *)requestWithType:(unsigned int)requestType data:(NSObject *)requestData channel:(Lookin_PTChannel *)channel;
- (RACSignal *)requestWithType:(unsigned int)requestType data:(NSObject *)requestData channel:(id<LookinChannelProtocol>)channel;

- (RACSignal<ECOChannelDeviceInfo *> *)connectToWireless:(ECOChannelDeviceInfo *)device;

- (NSArray<ECOChannelDeviceInfo *> *)getAllWirelessDevices;

- (BOOL)isWhiteListDevice:(ECOChannelDeviceInfo *)device;

- (void)setWhiteListDevice:(ECOChannelDeviceInfo *)device white:(BOOL)white;

/// 取消先前使用 requestWithType:data:channel: 方法发送的尚未完成的 request,这个 request 会被报告为 completion
- (void)cancelRequestWithType:(unsigned int)requestType channel:(Lookin_PTChannel *)channel;
- (void)cancelRequestWithType:(unsigned int)requestType channel:(id<LookinChannelProtocol>)channel;

/// 如果发送的消息不需要 server 端回复,则请使用该方法而非 requestWithType:
/// 如果此时 server 端不在前台或处于断点等模式,则 server 端可能无法收到该消息
- (void)pushWithType:(unsigned int)pushType data:(NSObject *)requestData channel:(Lookin_PTChannel *)channel;
- (void)pushWithType:(unsigned int)pushType data:(NSObject *)requestData channel:(id<LookinChannelProtocol>)channel;

/// 即将关闭某个 channel,一般是因为 server 端断开(比如 iOS app 被 kill 掉或 USB 被拔掉)
@property(nonatomic, strong, readonly) RACSubject *channelWillEnd;
Expand All @@ -46,3 +64,17 @@
@property(nonatomic, strong, readonly) RACSubject *didReceivePush;

@end

@interface Lookin_PTChannel (LKConnection) <LookinChannelProtocol>

/// 已经发送但尚未收到全部回复的请求
@property(nonatomic, strong) NSMutableSet<LKConnectionRequest *> *activeRequests;

@end

@interface ECOChannelDeviceInfo (LKConnection) <LookinChannelProtocol>

/// 已经发送但尚未收到全部回复的请求
@property(nonatomic, strong) NSMutableSet<LKConnectionRequest *> *activeRequests;

@end
Loading