[cim-ios-oc-sdk]增加重构代码

This commit is contained in:
Chentao 2022-09-16 13:35:24 +08:00
parent 560da9bebe
commit 2a2613b5cc
45 changed files with 3180 additions and 0 deletions

View File

@ -0,0 +1,480 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 55;
objects = {
/* Begin PBXBuildFile section */
C625DCFE28BF1106008F267F /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C625DCFD28BF1106008F267F /* AppDelegate.m */; };
C625DD0128BF1106008F267F /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C625DD0028BF1106008F267F /* SceneDelegate.m */; };
C625DD0428BF1106008F267F /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C625DD0328BF1106008F267F /* ViewController.m */; };
C625DD0728BF1106008F267F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C625DD0528BF1106008F267F /* Main.storyboard */; };
C625DD0928BF1108008F267F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C625DD0828BF1108008F267F /* Assets.xcassets */; };
C625DD0C28BF1108008F267F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C625DD0A28BF1108008F267F /* LaunchScreen.storyboard */; };
C625DD0F28BF1108008F267F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C625DD0E28BF1108008F267F /* main.m */; };
C625DD1828BF2BDF008F267F /* CIMService.m in Sources */ = {isa = PBXBuildFile; fileRef = C625DD1728BF2BDF008F267F /* CIMService.m */; };
C66CFB5528BF9000002506AD /* CIMMessageModel.m in Sources */ = {isa = PBXBuildFile; fileRef = C66CFB5428BF9000002506AD /* CIMMessageModel.m */; };
C66CFB6928C07ED5002506AD /* ReplyBody.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = C66CFB6428C07ED5002506AD /* ReplyBody.pbobjc.m */; };
C66CFB6A28C07ED5002506AD /* Message.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = C66CFB6528C07ED5002506AD /* Message.pbobjc.m */; };
C66CFB6B28C07ED5002506AD /* SentBody.pbobjc.m in Sources */ = {isa = PBXBuildFile; fileRef = C66CFB6728C07ED5002506AD /* SentBody.pbobjc.m */; };
C66CFB6E28C1B19C002506AD /* CIMSignalService.m in Sources */ = {isa = PBXBuildFile; fileRef = C66CFB6D28C1B19C002506AD /* CIMSignalService.m */; };
C66CFB7828C3548F002506AD /* CIMSignalServiceBuffer.m in Sources */ = {isa = PBXBuildFile; fileRef = C66CFB7728C3548F002506AD /* CIMSignalServiceBuffer.m */; };
C66CFB7B28C38D8E002506AD /* CIMSignalPacket.m in Sources */ = {isa = PBXBuildFile; fileRef = C66CFB7A28C38D8E002506AD /* CIMSignalPacket.m */; };
C68DFB5528D210790088E639 /* KCLDataWriter.m in Sources */ = {isa = PBXBuildFile; fileRef = C68DFB4E28D210790088E639 /* KCLDataWriter.m */; };
C68DFB5628D210790088E639 /* KCLDataReader.m in Sources */ = {isa = PBXBuildFile; fileRef = C68DFB5128D210790088E639 /* KCLDataReader.m */; };
C68DFB5728D210790088E639 /* CIMWeakProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = C68DFB5328D210790088E639 /* CIMWeakProxy.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
C625DCF928BF1106008F267F /* CIMKit.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CIMKit.app; sourceTree = BUILT_PRODUCTS_DIR; };
C625DCFC28BF1106008F267F /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
C625DCFD28BF1106008F267F /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
C625DCFF28BF1106008F267F /* SceneDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SceneDelegate.h; sourceTree = "<group>"; };
C625DD0028BF1106008F267F /* SceneDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SceneDelegate.m; sourceTree = "<group>"; };
C625DD0228BF1106008F267F /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
C625DD0328BF1106008F267F /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
C625DD0628BF1106008F267F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
C625DD0828BF1108008F267F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
C625DD0B28BF1108008F267F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
C625DD0D28BF1108008F267F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
C625DD0E28BF1108008F267F /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
C625DD1628BF2BDE008F267F /* CIMService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CIMService.h; sourceTree = "<group>"; };
C625DD1728BF2BDF008F267F /* CIMService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CIMService.m; sourceTree = "<group>"; };
C66CFB5328BF9000002506AD /* CIMMessageModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CIMMessageModel.h; sourceTree = "<group>"; };
C66CFB5428BF9000002506AD /* CIMMessageModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CIMMessageModel.m; sourceTree = "<group>"; };
C66CFB6328C07ED5002506AD /* SentBody.pbobjc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SentBody.pbobjc.h; sourceTree = "<group>"; };
C66CFB6428C07ED5002506AD /* ReplyBody.pbobjc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReplyBody.pbobjc.m; sourceTree = "<group>"; };
C66CFB6528C07ED5002506AD /* Message.pbobjc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Message.pbobjc.m; sourceTree = "<group>"; };
C66CFB6628C07ED5002506AD /* ReplyBody.pbobjc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReplyBody.pbobjc.h; sourceTree = "<group>"; };
C66CFB6728C07ED5002506AD /* SentBody.pbobjc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentBody.pbobjc.m; sourceTree = "<group>"; };
C66CFB6828C07ED5002506AD /* Message.pbobjc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Message.pbobjc.h; sourceTree = "<group>"; };
C66CFB6C28C1B19C002506AD /* CIMSignalService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CIMSignalService.h; sourceTree = "<group>"; };
C66CFB6D28C1B19C002506AD /* CIMSignalService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CIMSignalService.m; sourceTree = "<group>"; };
C66CFB7628C3548F002506AD /* CIMSignalServiceBuffer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CIMSignalServiceBuffer.h; sourceTree = "<group>"; };
C66CFB7728C3548F002506AD /* CIMSignalServiceBuffer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CIMSignalServiceBuffer.m; sourceTree = "<group>"; };
C66CFB7928C38D8E002506AD /* CIMSignalPacket.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CIMSignalPacket.h; sourceTree = "<group>"; };
C66CFB7A28C38D8E002506AD /* CIMSignalPacket.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CIMSignalPacket.m; sourceTree = "<group>"; };
C68DFB4E28D210790088E639 /* KCLDataWriter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KCLDataWriter.m; sourceTree = "<group>"; };
C68DFB4F28D210790088E639 /* KCLDataReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KCLDataReader.h; sourceTree = "<group>"; };
C68DFB5028D210790088E639 /* KCLDataWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KCLDataWriter.h; sourceTree = "<group>"; };
C68DFB5128D210790088E639 /* KCLDataReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KCLDataReader.m; sourceTree = "<group>"; };
C68DFB5328D210790088E639 /* CIMWeakProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CIMWeakProxy.m; sourceTree = "<group>"; };
C68DFB5428D210790088E639 /* CIMWeakProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CIMWeakProxy.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
C625DCF628BF1106008F267F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
B17C5FA540C326B8C638FB9C /* Pods */ = {
isa = PBXGroup;
children = (
);
path = Pods;
sourceTree = "<group>";
};
C625DCF028BF1105008F267F = {
isa = PBXGroup;
children = (
C625DCFB28BF1106008F267F /* CIMKit */,
C625DCFA28BF1106008F267F /* Products */,
B17C5FA540C326B8C638FB9C /* Pods */,
);
sourceTree = "<group>";
};
C625DCFA28BF1106008F267F /* Products */ = {
isa = PBXGroup;
children = (
C625DCF928BF1106008F267F /* CIMKit.app */,
);
name = Products;
sourceTree = "<group>";
};
C625DCFB28BF1106008F267F /* CIMKit */ = {
isa = PBXGroup;
children = (
C625DD1528BF2BA0008F267F /* CIMKit */,
C625DCFC28BF1106008F267F /* AppDelegate.h */,
C625DCFD28BF1106008F267F /* AppDelegate.m */,
C625DCFF28BF1106008F267F /* SceneDelegate.h */,
C625DD0028BF1106008F267F /* SceneDelegate.m */,
C625DD0228BF1106008F267F /* ViewController.h */,
C625DD0328BF1106008F267F /* ViewController.m */,
C625DD0528BF1106008F267F /* Main.storyboard */,
C625DD0828BF1108008F267F /* Assets.xcassets */,
C625DD0A28BF1108008F267F /* LaunchScreen.storyboard */,
C625DD0D28BF1108008F267F /* Info.plist */,
C625DD0E28BF1108008F267F /* main.m */,
);
path = CIMKit;
sourceTree = "<group>";
};
C625DD1528BF2BA0008F267F /* CIMKit */ = {
isa = PBXGroup;
children = (
C68DFB4C28D210790088E639 /* Tool */,
C66CFB6228C07ED5002506AD /* Proto */,
C625DD1628BF2BDE008F267F /* CIMService.h */,
C625DD1728BF2BDF008F267F /* CIMService.m */,
C66CFB6C28C1B19C002506AD /* CIMSignalService.h */,
C66CFB6D28C1B19C002506AD /* CIMSignalService.m */,
C66CFB7628C3548F002506AD /* CIMSignalServiceBuffer.h */,
C66CFB7728C3548F002506AD /* CIMSignalServiceBuffer.m */,
C66CFB7928C38D8E002506AD /* CIMSignalPacket.h */,
C66CFB7A28C38D8E002506AD /* CIMSignalPacket.m */,
C66CFB5328BF9000002506AD /* CIMMessageModel.h */,
C66CFB5428BF9000002506AD /* CIMMessageModel.m */,
);
path = CIMKit;
sourceTree = "<group>";
};
C66CFB6228C07ED5002506AD /* Proto */ = {
isa = PBXGroup;
children = (
C66CFB6328C07ED5002506AD /* SentBody.pbobjc.h */,
C66CFB6728C07ED5002506AD /* SentBody.pbobjc.m */,
C66CFB6628C07ED5002506AD /* ReplyBody.pbobjc.h */,
C66CFB6428C07ED5002506AD /* ReplyBody.pbobjc.m */,
C66CFB6828C07ED5002506AD /* Message.pbobjc.h */,
C66CFB6528C07ED5002506AD /* Message.pbobjc.m */,
);
path = Proto;
sourceTree = "<group>";
};
C68DFB4C28D210790088E639 /* Tool */ = {
isa = PBXGroup;
children = (
C68DFB4D28D210790088E639 /* KCLDataReaderWriter */,
C68DFB5228D210790088E639 /* CIMWeakProxy */,
);
path = Tool;
sourceTree = "<group>";
};
C68DFB4D28D210790088E639 /* KCLDataReaderWriter */ = {
isa = PBXGroup;
children = (
C68DFB4E28D210790088E639 /* KCLDataWriter.m */,
C68DFB4F28D210790088E639 /* KCLDataReader.h */,
C68DFB5028D210790088E639 /* KCLDataWriter.h */,
C68DFB5128D210790088E639 /* KCLDataReader.m */,
);
path = KCLDataReaderWriter;
sourceTree = "<group>";
};
C68DFB5228D210790088E639 /* CIMWeakProxy */ = {
isa = PBXGroup;
children = (
C68DFB5328D210790088E639 /* CIMWeakProxy.m */,
C68DFB5428D210790088E639 /* CIMWeakProxy.h */,
);
path = CIMWeakProxy;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
C625DCF828BF1106008F267F /* CIMKit */ = {
isa = PBXNativeTarget;
buildConfigurationList = C625DD1228BF1108008F267F /* Build configuration list for PBXNativeTarget "CIMKit" */;
buildPhases = (
C625DCF528BF1106008F267F /* Sources */,
C625DCF628BF1106008F267F /* Frameworks */,
C625DCF728BF1106008F267F /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = CIMKit;
productName = CIMKit;
productReference = C625DCF928BF1106008F267F /* CIMKit.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
C625DCF128BF1105008F267F /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastUpgradeCheck = 1340;
TargetAttributes = {
C625DCF828BF1106008F267F = {
CreatedOnToolsVersion = 13.4;
};
};
};
buildConfigurationList = C625DCF428BF1105008F267F /* Build configuration list for PBXProject "CIMKit" */;
compatibilityVersion = "Xcode 13.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = C625DCF028BF1105008F267F;
productRefGroup = C625DCFA28BF1106008F267F /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
C625DCF828BF1106008F267F /* CIMKit */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
C625DCF728BF1106008F267F /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C625DD0C28BF1108008F267F /* LaunchScreen.storyboard in Resources */,
C625DD0928BF1108008F267F /* Assets.xcassets in Resources */,
C625DD0728BF1106008F267F /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
C625DCF528BF1106008F267F /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C66CFB7828C3548F002506AD /* CIMSignalServiceBuffer.m in Sources */,
C68DFB5728D210790088E639 /* CIMWeakProxy.m in Sources */,
C625DD0428BF1106008F267F /* ViewController.m in Sources */,
C66CFB5528BF9000002506AD /* CIMMessageModel.m in Sources */,
C66CFB6B28C07ED5002506AD /* SentBody.pbobjc.m in Sources */,
C66CFB7B28C38D8E002506AD /* CIMSignalPacket.m in Sources */,
C68DFB5528D210790088E639 /* KCLDataWriter.m in Sources */,
C625DCFE28BF1106008F267F /* AppDelegate.m in Sources */,
C625DD0F28BF1108008F267F /* main.m in Sources */,
C625DD1828BF2BDF008F267F /* CIMService.m in Sources */,
C68DFB5628D210790088E639 /* KCLDataReader.m in Sources */,
C66CFB6928C07ED5002506AD /* ReplyBody.pbobjc.m in Sources */,
C66CFB6E28C1B19C002506AD /* CIMSignalService.m in Sources */,
C66CFB6A28C07ED5002506AD /* Message.pbobjc.m in Sources */,
C625DD0128BF1106008F267F /* SceneDelegate.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
C625DD0528BF1106008F267F /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
C625DD0628BF1106008F267F /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
C625DD0A28BF1108008F267F /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
C625DD0B28BF1108008F267F /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
C625DD1028BF1108008F267F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
};
C625DD1128BF1108008F267F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
C625DD1328BF1108008F267F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = H6UN23L6E6;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = CIMKit/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.chen.CIMKit;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
C625DD1428BF1108008F267F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = H6UN23L6E6;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = CIMKit/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.chen.CIMKit;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
C625DCF428BF1105008F267F /* Build configuration list for PBXProject "CIMKit" */ = {
isa = XCConfigurationList;
buildConfigurations = (
C625DD1028BF1108008F267F /* Debug */,
C625DD1128BF1108008F267F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C625DD1228BF1108008F267F /* Build configuration list for PBXNativeTarget "CIMKit" */ = {
isa = XCConfigurationList;
buildConfigurations = (
C625DD1328BF1108008F267F /* Debug */,
C625DD1428BF1108008F267F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = C625DCF128BF1105008F267F /* Project object */;
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>CIMKit.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>3</integer>
</dict>
</dict>
</dict>
</plist>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:CIMKit.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,168 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "042D2A47-E033-4FB6-831C-62051BE0DD2C"
type = "0"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "B2111124-DE40-441F-B9F6-097D555E9935"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "CIMKit/Class/CIMSendMessageData.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "17"
endingLineNumber = "17"
landmarkName = "+initHeartbeatData"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "2389BB28-5472-4BB3-87D5-EA288B0D3ABB"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "CIMKit/Class/Tool/NSString+IM.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "18"
endingLineNumber = "18"
landmarkName = "-convertBytesStringToData"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "F989D3DE-3E36-4658-952A-6DDDC1CD0582"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "CIMKit/ViewController.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "76"
endingLineNumber = "76"
landmarkName = "-cimDidBindUserSuccess:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "02CD0C33-AB44-4BB3-9E83-1CFBB8666E17"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "CIMKit/ViewController.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "87"
endingLineNumber = "87"
landmarkName = "-cimDidConnectError:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "3E5ADEAB-4FBE-40A2-9344-6B5CB8A7291B"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "CIMKit/ViewController.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "90"
endingLineNumber = "90"
landmarkName = "ViewController"
landmarkType = "3">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "D1E5A5E8-D161-4CB9-A00D-F4AAC8FDD8BD"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "CIMKit/ViewController.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "95"
endingLineNumber = "95"
landmarkName = "-cimHandleMessageError:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "347B18CB-3F11-4A42-960A-F42941969893"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "CIMKit/ViewController.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "98"
endingLineNumber = "98"
landmarkName = "ViewController"
landmarkType = "3">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "15F4EEA7-FF1A-4CED-8974-7428222E9853"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "CIMKit/ViewController.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "79"
endingLineNumber = "79"
landmarkName = "-cimDidConnectSuccess"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "CF67C50F-634D-4884-AC44-3B4383833873"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "CIMKit/Class/CIMService.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "299"
endingLineNumber = "299"
landmarkName = "-disconnect"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "A766F010-D0DC-425A-AFB6-8AEA573D5575"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "CIMKit/Class/CIMSignalService.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "99"
endingLineNumber = "99"
landmarkName = "-socketDidDisconnect:withError:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

View File

@ -0,0 +1,14 @@
//
// AppDelegate.h
// CIMKit
//
// Created by Chentao on 2022/8/31.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@end

View File

@ -0,0 +1,43 @@
//
// AppDelegate.m
// CIMKit
//
// Created by Chentao on 2022/8/31.
//
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
return YES;
}
#pragma mark - UISceneSession lifecycle
- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
}
- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
@end

View File

@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,93 @@
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>

View File

@ -0,0 +1,34 @@
//
// CIMMessageModel.h
// CIMKit
//
// Created by Chentao on 2022/8/31.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface CIMMessageModel : NSObject
@property (nonatomic, readwrite) int64_t id_p;
@property (nonatomic, readwrite, copy) NSString *action;
@property (nonatomic, readwrite, copy) NSString *content;
@property (nonatomic, readwrite, copy) NSString *sender;
@property (nonatomic, readwrite, copy) NSString *receiver;
@property (nonatomic, readwrite, copy) NSString *extra;
@property (nonatomic, readwrite, copy) NSString *title;
@property (nonatomic, readwrite, copy) NSString *format;
@property (nonatomic, readwrite) int64_t timestamp;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,12 @@
//
// CIMMessageModel.m
// CIMKit
//
// Created by Chentao on 2022/8/31.
//
#import "CIMMessageModel.h"
@implementation CIMMessageModel
@end

View File

@ -0,0 +1,148 @@
//
// CIMService.h
// CIMKit
//
// Created by Chentao on 2022/9/4.
//
//
#import <Foundation/Foundation.h>
#import "CIMMessageModel.h"
NS_ASSUME_NONNULL_BEGIN
@class CIMService;
/**
*/
@protocol CIMPeerMessageObserver <NSObject>
/**
*/
- (void)cimHandleMessage:(CIMMessageModel *_Nonnull)msg;
/**
*/
- (void)cimHandleMessageError:(NSData *_Nonnull)data;
@end
/**
*/
@protocol CIMConnectionObserver <NSObject>
@optional
/**
*/
- (void)cimDidBindUserSuccess:(BOOL)bindSuccess;
/**
*/
- (void)cimDidConnectSuccess;
/**
*/
- (void)cimDidReconnection:(NSInteger)reconnectionCount;
/**
*/
- (void)cimDidConnectClose;
/**
*/
- (void)cimDidConnectError:(NSError *_Nullable)error;
@end
@interface CIMService : NSObject
+ (CIMService *)instance;
@property (nonatomic, readonly) BOOL isConnected;
/**
,reconnection = YES reconnection = NO
reconnection = YES
reconnectionTimeInterval和reconnectionMaxCount影响
*/
@property (nonatomic, assign) BOOL reconnection;
/**
reconnection = YES时自动重连的时间间隔reconnectionTimeInterval=1.0
*/
@property (nonatomic, assign) NSTimeInterval reconnectionTimeInterval;
/**
reconnection = YES时自动重连的最大次数reconnectionMaxCount=3
*/
@property (nonatomic, assign) NSInteger reconnectionMaxCount;
/**
IM服务器
*/
- (void)configHost:(NSString *)host onPort:(NSInteger)port;
/**
host:port对应的服务器
*/
- (void)connection;
/**
userId,isConnected判断当前连接的状态
isConnected=NO需要先调用[[CIMService instance] connection],[[CIMService instance] bindUserId:];
isConnected=YES,[[CIMService instance] bindUserId:];
*/
- (void)bindUserId:(NSString *)userId;
/**
,()Remove
*/
- (void)addMessageObserver:(id<CIMPeerMessageObserver>)observer;
/**
*/
- (void)removeMessageObserver:(id<CIMPeerMessageObserver>)observer;
/**
,()Remove
*/
- (void)addConnectionObserver:(id<CIMConnectionObserver>)observer;
/**
*/
- (void)removeConnectionObserver:(id<CIMConnectionObserver>)observer;
/**
退
*/
- (void)enterBackground;
/**
*/
- (void)enterForeground;
/**
*/
- (void)reconnect;
/**
*/
- (void)disconnect;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,417 @@
//
// CIMService.m
// CIMKit
//
// Created by Chentao on 2022/9/4.
//
//
#import "CIMService.h"
#import "CIMSignalService.h"
#import "SentBody.pbobjc.h"
#import "ReplyBody.pbobjc.h"
#import "Message.pbobjc.h"
#import <UIKit/UIKit.h>
#import "CIMWeakProxy.h"
@interface CIMService ()<CIMSignalServiceDelegate>
@property (nonatomic, strong) CIMSignalService *signalService;
@property (nonatomic, strong) NSMutableArray<CIMConnectionObserver> *connectionObservers;
@property (nonatomic, strong) NSMutableArray<CIMPeerMessageObserver> *messageObservers;
@property (nonatomic, assign) BOOL manualDisconnect;
@property (nonatomic, assign) NSInteger reconnectionCount;
@property (nonatomic, strong) NSTimer *reconnectionTimer;
@end
@implementation CIMService
static CIMService *SINGLETON = nil;
static bool isFirstAccess = YES;
#pragma mark - Public Method
+ (id)instance {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
isFirstAccess = NO;
SINGLETON = [[super allocWithZone:NULL] init];
});
return SINGLETON;
}
#pragma mark - Life Cycle
+ (id)allocWithZone:(NSZone *)zone {
return [self instance];
}
- (id)copy {
return [[CIMService alloc] init];
}
- (id)mutableCopy {
return [[CIMService alloc] init];
}
- (id)init {
if (SINGLETON) {
return SINGLETON;
}
if (isFirstAccess) {
[self doesNotRecognizeSelector:_cmd];
}
self = [super init];
self.reconnection = YES;
self.reconnectionTimeInterval = 1.0;
self.reconnectionMaxCount = 3;
self.reconnectionCount = 0;
return self;
}
#pragma mark - connectionObservers
- (NSMutableArray<CIMConnectionObserver> *)connectionObservers {
if (!_connectionObservers) {
_connectionObservers = [[NSMutableArray<CIMConnectionObserver> alloc] init];
}
return _connectionObservers;
}
- (void)addConnectionObserver:(id<CIMConnectionObserver>)observer {
NSValue *value = [NSValue valueWithNonretainedObject:observer];
if (![self.connectionObservers containsObject:value]) {
[self.connectionObservers addObject:value];
}
}
- (void)removeConnectionObserver:(id<CIMConnectionObserver>)observer {
NSValue *value = [NSValue valueWithNonretainedObject:observer];
if ([self.connectionObservers containsObject:value]) {
[self.connectionObservers removeObject:value];
}
}
#pragma mark - messageObservers
- (NSMutableArray<CIMPeerMessageObserver> *)messageObservers {
if (!_messageObservers) {
_messageObservers = [[NSMutableArray<CIMPeerMessageObserver> alloc] init];
}
return _messageObservers;
}
- (void)addMessageObserver:(id<CIMPeerMessageObserver>)observer {
NSValue *value = [NSValue valueWithNonretainedObject:observer];
if (![self.messageObservers containsObject:value]) {
[self.messageObservers addObject:value];
}
}
- (void)removeMessageObserver:(id<CIMPeerMessageObserver>)observer {
NSValue *value = [NSValue valueWithNonretainedObject:observer];
if ([self.messageObservers containsObject:value]) {
[self.messageObservers removeObject:value];
}
}
#pragma mark - signalService
- (CIMSignalService *)signalService {
if (!_signalService) {
_signalService = [[CIMSignalService alloc] init];
_signalService.delegate = self;
}
return _signalService;
}
#pragma mark - CIMSignalServiceDelegate
/**
*
**/
- (void)signalServiceWillConnect:(CIMSignalService *)signalService {
}
/**
*
**/
- (void)signalServiceWillConnect:(CIMSignalService *)signalService error:(NSError *)error {
[self handlerConnectError:error];
}
/**
*
**/
- (void)signalServiceConnectSuccess:(CIMSignalService *)signalService {
self.manualDisconnect = NO;
self.reconnectionCount = 0;
[self handlerConnectSuccess];
}
/**
*
**/
- (void)signalServiceDidDisconnect:(CIMSignalService *)signalService error:(NSError *)error {
if (!self.manualDisconnect && self.reconnection && self.reconnectionCount < self.reconnectionMaxCount) {
// reconnectionCount < reconnectionMaxCount
[self startReconnectionTimer];
} else {
[self handlerConnectClose];
}
}
/**
*
**/
- (void)signalService:(CIMSignalService *)signalService receivePacket:(CIMSignalPacket *)packet {
switch (packet.tag) {
case CIMSignalPacketTypePing:{
NSLog(@"receive Ping");
CIMSignalPacket *pongSignalPacket = [self createPongPacket];
[self.signalService sendSignalPacket:pongSignalPacket];
break;
}
case CIMSignalPacketTypeMessage:{
NSLog(@"receive Message");
NSError *error;
MessageModel *messgae = [[MessageModel alloc] initWithData:packet.packetBody error:&error];
if (!error) {
//
CIMMessageModel *messageModel = [[CIMMessageModel alloc] init];
messageModel.id_p = messgae.id_p;
messageModel.title = messgae.title;
messageModel.action = messgae.action;
messageModel.timestamp = messgae.timestamp;
messageModel.extra = messgae.extra;
messageModel.format = messgae.format;
messageModel.sender = messgae.sender;
messageModel.content = messgae.content;
messageModel.receiver = messgae.receiver;
[self handlerMessage:messageModel];
} else {
[self handlerMessageError:packet.packetBody];
}
break;
}
case CIMSignalPacketTypeReplyBody:{
NSLog(@"receive ReplyBody");
NSError *error;
ReplyBodyModel *replyBodyModel = [[ReplyBodyModel alloc] initWithData:packet.packetBody error:&error];
if (!error) {
[self handlerBindUser:[@"200" isEqualToString:replyBodyModel.code]];
} else {
[self handlerBindUser:NO];
}
break;
}
default:{
break;
}
}
}
#pragma mark -
- (void)startReconnectionTimer {
[self stopReconnectionTimer];
self.reconnectionTimer = [NSTimer timerWithTimeInterval:self.reconnectionTimeInterval target:[CIMWeakProxy proxyWithTarget:self] selector:@selector(reconnectionTimerHandler) userInfo:nil repeats:NO];
[NSRunLoop.mainRunLoop addTimer:self.reconnectionTimer forMode:NSRunLoopCommonModes];
}
- (void)stopReconnectionTimer {
if (self.reconnectionTimer) {
[self.reconnectionTimer invalidate];
self.reconnectionTimer = nil;
}
}
- (void)reconnectionTimerHandler {
self.reconnectionCount += 1;
[self handlerDidReconnection:self.reconnectionCount];
[self connection];
}
#pragma mark - public
- (void)configHost:(NSString *)host onPort:(NSInteger)port {
CIMSignalServiceConfig *config = [[CIMSignalServiceConfig alloc] init];
config.host = host;
config.port = port;
self.signalService.serviceConfig = config;
}
- (void)connection {
if (self.signalService.isConnected) {
return;
}
[self.signalService connect];
}
- (void)bindUserId:(NSString *)userId {
if (self.signalService.isConnected) {
CIMSignalPacket *clientBindPacket = [self createClientBindPacketWithUserId:userId];
[self.signalService sendSignalPacket:clientBindPacket];
}
}
- (void)enterBackground {
[self disconnect];
}
- (void)enterForeground {
[self reconnect];
}
- (void)reconnect {
[self connection];
}
- (void)disconnect {
if (self.signalService.isConnected) {
self.manualDisconnect = YES;
[self stopReconnectionTimer];
[self.signalService close];
}
}
#pragma mark -
- (void)handlerConnectSuccess {
for (NSValue *value in self.messageObservers) {
id<CIMConnectionObserver> ob = [value nonretainedObjectValue];
if ([ob respondsToSelector:@selector(cimDidConnectSuccess)]) {
[ob cimDidConnectSuccess];
}
}
}
- (void)handlerDidReconnection:(NSInteger)count {
for (NSValue *value in self.connectionObservers) {
id<CIMConnectionObserver> ob = [value nonretainedObjectValue];
if ([ob respondsToSelector:@selector(cimDidReconnection:)]) {
[ob cimDidReconnection:count];
}
}
}
- (void)handlerConnectClose {
for (NSValue *value in self.connectionObservers) {
id<CIMConnectionObserver> ob = [value nonretainedObjectValue];
if ([ob respondsToSelector:@selector(cimDidConnectClose)]) {
[ob cimDidConnectClose];
}
}
}
- (void)handlerConnectError:(NSError *)error {
for (NSValue *value in self.messageObservers) {
id<CIMConnectionObserver> ob = [value nonretainedObjectValue];
if ([ob respondsToSelector:@selector(cimDidConnectError:)]) {
[ob cimDidConnectError:error];
}
}
}
- (void)handlerMessageError:(NSData *)data {
for (NSValue *value in self.messageObservers) {
id<CIMPeerMessageObserver> ob = [value nonretainedObjectValue];
if ([ob respondsToSelector:@selector(cimHandleMessageError:)]) {
[ob cimHandleMessageError:data];
}
}
}
- (void)handlerMessage:(CIMMessageModel *)message {
for (NSValue *value in self.messageObservers) {
id<CIMPeerMessageObserver> ob = [value nonretainedObjectValue];
if ([ob respondsToSelector:@selector(cimHandleMessage:)]) {
[ob cimHandleMessage:message];
}
}
}
- (void)handlerBindUser:(BOOL)bindSuccess {
for (NSValue *value in self.connectionObservers) {
id<CIMConnectionObserver> ob = [value nonretainedObjectValue];
if ([ob respondsToSelector:@selector(cimDidBindUserSuccess:)]) {
[ob cimDidBindUserSuccess:bindSuccess];
}
}
}
- (CIMSignalPacket *)createClientBindPacketWithUserId:(NSString *)userId {
SentBodyModel *clientBindBody = [SentBodyModel new];
clientBindBody.key = @"client_bind";
clientBindBody.timestamp = (int64_t)[NSDate timeIntervalSinceReferenceDate] * 1000;
clientBindBody.data_p[@"uid"] = userId;
clientBindBody.data_p[@"deviceId"] = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
clientBindBody.data_p[@"channel"] = @"ios";
clientBindBody.data_p[@"deviceName"] = [[UIDevice currentDevice] name];
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
clientBindBody.data_p[@"appVersion"] = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
clientBindBody.data_p[@"osVersion"] = [[UIDevice currentDevice] systemVersion];
NSArray<NSString *> *languages = [NSLocale preferredLanguages];
clientBindBody.data_p[@"language"] = [languages firstObject];
NSData *bodyData = clientBindBody.data;
CIMSignalPacket *clientBindPacket = [[CIMSignalPacket alloc] init];
clientBindPacket.tag = CIMSignalPacketTypeSentBody;
clientBindPacket.bodyLength = bodyData.length;
clientBindPacket.packetBody = bodyData;
return clientBindPacket;
}
- (CIMSignalPacket *)createPongPacket {
CIMSignalPacket *pongPacket = [[CIMSignalPacket alloc] init];
pongPacket.tag = CIMSignalPacketTypePong;
NSString *pong = @"PONG";
const char *pongChar = [pong cStringUsingEncoding:NSASCIIStringEncoding];
UInt16 lenght = pong.length;
NSData *bodyData = [NSData dataWithBytes:pongChar length:lenght];
pongPacket.bodyLength = bodyData.length;
pongPacket.packetBody = bodyData;
return pongPacket;
}
@end

View File

@ -0,0 +1,30 @@
//
// CIMSignalPacket.h
// CIMKit
//
// Created by Chentao on 2022/9/3.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
extern UInt8 const CIMSIGNAL_PACKET_HEAD_SIZE;
typedef NS_ENUM(UInt8, CIMSignalPacketType) {
CIMSignalPacketTypePong = 0, //PONG
CIMSignalPacketTypePing = 1, //PING
CIMSignalPacketTypeMessage = 2, //Message
CIMSignalPacketTypeSentBody = 3, //SentBody
CIMSignalPacketTypeReplyBody = 4, //ReplyBody
};
@interface CIMSignalPacket : NSObject
@property (nonatomic, assign) CIMSignalPacketType tag;
@property (nonatomic, assign) UInt16 bodyLength;
@property (nonatomic, strong) NSData *packetBody;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,14 @@
//
// CIMSignalPacket.m
// CIMKit
//
// Created by Chentao on 2022/9/3.
//
#import "CIMSignalPacket.h"
UInt8 const CIMSIGNAL_PACKET_HEAD_SIZE = 3;
@implementation CIMSignalPacket
@end

View File

@ -0,0 +1,65 @@
//
// CIMSignalService.h
// CIMKit
//
// Created by Chentao on 2022/9/2.
//
#import <Foundation/Foundation.h>
#import "CIMSignalPacket.h"
NS_ASSUME_NONNULL_BEGIN
@interface CIMSignalServiceConfig : NSObject
@property (nonatomic, copy) NSString *host;
@property (nonatomic, assign) NSInteger port;
@end
@class CIMSignalService;
@protocol CIMSignalServiceDelegate <NSObject>
/**
*
**/
- (void)signalServiceWillConnect:(CIMSignalService *)signalService;
/**
*
**/
- (void)signalServiceWillConnect:(CIMSignalService *)signalService error:(NSError *)error;
/**
*
**/
- (void)signalServiceConnectSuccess:(CIMSignalService *)signalService;
/**
*
**/
- (void)signalServiceDidDisconnect:(CIMSignalService *)signalService error:(NSError *)error;
/**
*
**/
- (void)signalService:(CIMSignalService *)signalService receivePacket:(CIMSignalPacket *)packet;
@end
@interface CIMSignalService : NSObject
@property (nonatomic, weak) id<CIMSignalServiceDelegate> delegate;
@property (nonatomic, strong) CIMSignalServiceConfig *serviceConfig;
@property (nonatomic, readonly) BOOL isConnected;
- (void)connect;
- (void)close;
- (void)sendSignalPacket:(CIMSignalPacket *)signalPacket;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,129 @@
//
// CIMSignalService.m
// CIMKit
//
// Created by Chentao on 2022/9/2.
//
#import "CIMSignalService.h"
#import "GCDAsyncSocket.h"
#import "CIMSignalServiceBuffer.h"
#import "KCLDataWriter.h"
@implementation CIMSignalServiceConfig
@end
@interface CIMSignalService ()<GCDAsyncSocketDelegate, CIMSignalServiceBufferDelegate>
@property (nonatomic, strong) NSLock *signalBufferLock;
@property (nonatomic, strong) CIMSignalServiceBuffer *signalBuffer;
@property (nonatomic, strong) GCDAsyncSocket *socket;
@end
@implementation CIMSignalService
- (instancetype)init {
self = [super init];
if (self) {
self.socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_queue_create("SignalServiceQueue", NULL)];
self.signalBufferLock = [[NSLock alloc]init];
self.signalBuffer = [[CIMSignalServiceBuffer alloc] init];
self.signalBuffer.delegate = self;
}
return self;
}
- (BOOL)isConnected {
return self.socket.isConnected;
}
- (void)connect {
if (self.delegate && [self.delegate respondsToSelector:@selector(signalServiceWillConnect:)]) {
[self.delegate signalServiceWillConnect:self];
}
NSError *error;
[self.socket connectToHost:self.serviceConfig.host onPort:self.serviceConfig.port withTimeout:15 error:&error];
if (error) {
//NSLog(@"connect error:%@", error);
if (self.delegate && [self.delegate respondsToSelector:@selector(signalServiceWillConnect:error:)]) {
[self.delegate signalServiceWillConnect:self error:error];
}
}
}
- (void)close {
[self.socket disconnect];
}
- (void)sendSignalPacket:(CIMSignalPacket *)signalPacket {
KCLDataWriter *dataWriter = [KCLDataWriter writerWithData:[[NSMutableData alloc] init]];
[dataWriter writeByte:signalPacket.tag];
[dataWriter writeUInt16:signalPacket.bodyLength];
if (signalPacket) {
[dataWriter writeBytes:signalPacket.packetBody];
}
[self.socket writeData:dataWriter.data withTimeout:30 tag:0];
}
#pragma mark - GCDAsyncSocketDelegate
- (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(uint16_t)port {
//NSLog(@"%s", __FUNCTION__);
[self.signalBufferLock lock];
[self.signalBuffer clear];
[self.signalBufferLock unlock];
[sock readDataWithTimeout:-1 tag:0];
dispatch_async(dispatch_get_main_queue(), ^{
if (self.delegate && [self.delegate respondsToSelector:@selector(signalServiceConnectSuccess:)]) {
[self.delegate signalServiceConnectSuccess:self];
}
});
}
- (void)socketDidDisconnect:(GCDAsyncSocket *)sock withError:(NSError *)error {
//NSLog(@"%s", __FUNCTION__);
dispatch_async(dispatch_get_main_queue(), ^{
if (self.delegate && [self.delegate respondsToSelector:@selector(signalServiceDidDisconnect:error:)]) {
[self.delegate signalServiceDidDisconnect:self error:error];
}
});
}
- (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag {
//NSLog(@"%s", __FUNCTION__);
[sock readDataWithTimeout:-1 tag:0];
}
- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag {
//NSLog(@"%s", __FUNCTION__);
[self.signalBufferLock lock];
[self.signalBuffer appendData:data];
[self.signalBufferLock unlock];
[sock readDataWithTimeout:-1 tag:0];
}
#pragma mark - CIMSignalServiceBufferDelegate
- (void)signalServiceBuffer:(CIMSignalServiceBuffer *)signalServiceBuffer receiveSignalPacket:(CIMSignalPacket *)signalPacket {
dispatch_async(dispatch_get_main_queue(), ^{
if (self.delegate && [self.delegate respondsToSelector:@selector(signalService:receivePacket:)]) {
[self.delegate signalService:self receivePacket:signalPacket];
}
});
}
@end

View File

@ -0,0 +1,29 @@
//
// CIMSignalServiceBuffer.h
// CIMKit
//
// Created by Chentao on 2022/9/3.
//
#import <Foundation/Foundation.h>
#import "CIMSignalPacket.h"
NS_ASSUME_NONNULL_BEGIN
@class CIMSignalServiceBuffer;
@protocol CIMSignalServiceBufferDelegate <NSObject>
- (void)signalServiceBuffer:(CIMSignalServiceBuffer *)signalServiceBuffer receiveSignalPacket:(CIMSignalPacket *)signalPacket;
@end
@interface CIMSignalServiceBuffer : NSObject
@property (nonatomic, weak) id <CIMSignalServiceBufferDelegate> delegate;
- (void)appendData:(NSData *)data;
- (void)clear;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,86 @@
//
// CIMSignalServiceBuffer.m
// CIMKit
//
// Created by Chentao on 2022/9/3.
//
#import "CIMSignalServiceBuffer.h"
@interface CIMSignalServiceBuffer ()
@property (nonatomic, strong) NSMutableData *byteDatas;
@end
@implementation CIMSignalServiceBuffer
- (instancetype)init {
self = [super init];
if (self) {
self.byteDatas = [[NSMutableData alloc] init];
}
return self;
}
- (void)appendData:(NSData *)data {
[self.byteDatas appendData:data];
BOOL hasPacket = YES;
while (hasPacket) {
@autoreleasepool {
if (CIMSIGNAL_PACKET_HEAD_SIZE <= self.byteDatas.length) {
NSData *headData = [self.byteDatas subdataWithRange:NSMakeRange(0, CIMSIGNAL_PACKET_HEAD_SIZE)];
uint8_t *ptr = (uint8_t *)headData.bytes;
uint64_t _poz = 0;
uint8_t tag = *(uint8_t *)ptr;
_poz += sizeof(uint8_t);
uint16_t bodyLength = *(uint16_t *)(ptr + _poz);
_poz += sizeof(uint16_t);
UInt32 packetSize = CIMSIGNAL_PACKET_HEAD_SIZE + bodyLength;
if (packetSize <= self.byteDatas.length) {
NSData *packetBody = [self.byteDatas subdataWithRange:NSMakeRange(CIMSIGNAL_PACKET_HEAD_SIZE, bodyLength)];
CIMSignalPacket *signalPacket = [[CIMSignalPacket alloc] init];
signalPacket.tag = tag;
signalPacket.bodyLength = bodyLength;
signalPacket.packetBody = packetBody;
if (self.delegate && [self.delegate respondsToSelector:@selector(signalServiceBuffer:receiveSignalPacket:)]) {
[self.delegate signalServiceBuffer:self receiveSignalPacket:signalPacket];
}
NSMutableData *newByteDatas = [self subdata:self.byteDatas loc:packetSize length:self.byteDatas.length - packetSize];
self.byteDatas = newByteDatas;
hasPacket = YES;
} else {
hasPacket = NO;
}
} else {
hasPacket = NO;
}
}
}
}
- (void)clear {
@autoreleasepool {
self.byteDatas = [[NSMutableData alloc] init];
}
}
- (NSMutableData *)subdata:(NSMutableData *)data loc:(NSUInteger)loc length:(NSUInteger)len {
NSRange subRange = NSMakeRange(loc, len);
NSMutableData *newByteDatas = [[NSMutableData alloc] initWithData:[data subdataWithRange:subRange]];
return newByteDatas;
}
@end

View File

@ -0,0 +1,89 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: Message.proto
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <Protobuf/GPBProtocolBuffers.h>
#else
#import "GPBProtocolBuffers.h"
#endif
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - MessageRoot
/**
* Exposes the extension registry for this file.
*
* The base class provides:
* @code
* + (GPBExtensionRegistry *)extensionRegistry;
* @endcode
* which is a @c GPBExtensionRegistry that includes all the extensions defined by
* this file and all files that it depends on.
**/
@interface MessageRoot : GPBRootObject
@end
#pragma mark - Model
typedef GPB_ENUM(MessageModel_FieldNumber) {
MessageModel_FieldNumber_Id_p = 1,
MessageModel_FieldNumber_Action = 2,
MessageModel_FieldNumber_Content = 3,
MessageModel_FieldNumber_Sender = 4,
MessageModel_FieldNumber_Receiver = 5,
MessageModel_FieldNumber_Extra = 6,
MessageModel_FieldNumber_Title = 7,
MessageModel_FieldNumber_Format = 8,
MessageModel_FieldNumber_Timestamp = 9,
};
@interface MessageModel : GPBMessage
@property(nonatomic, readwrite) int64_t id_p;
@property(nonatomic, readwrite, copy, null_resettable) NSString *action;
@property(nonatomic, readwrite, copy, null_resettable) NSString *content;
@property(nonatomic, readwrite, copy, null_resettable) NSString *sender;
@property(nonatomic, readwrite, copy, null_resettable) NSString *receiver;
@property(nonatomic, readwrite, copy, null_resettable) NSString *extra;
@property(nonatomic, readwrite, copy, null_resettable) NSString *title;
@property(nonatomic, readwrite, copy, null_resettable) NSString *format;
@property(nonatomic, readwrite) int64_t timestamp;
@end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)

View File

@ -0,0 +1,181 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: Message.proto
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <Protobuf/GPBProtocolBuffers_RuntimeSupport.h>
#else
#import "GPBProtocolBuffers_RuntimeSupport.h"
#endif
#import "Message.pbobjc.h"
// @@protoc_insertion_point(imports)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma mark - MessageRoot
@implementation MessageRoot
// No extensions in the file and no imports, so no need to generate
// +extensionRegistry.
@end
#pragma mark - MessageRoot_FileDescriptor
static GPBFileDescriptor *MessageRoot_FileDescriptor(void) {
// This is called by +initialize so there is no need to worry
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@""
syntax:GPBFileSyntaxProto3];
}
return descriptor;
}
#pragma mark - Model
@implementation MessageModel
@dynamic id_p;
@dynamic action;
@dynamic content;
@dynamic sender;
@dynamic receiver;
@dynamic extra;
@dynamic title;
@dynamic format;
@dynamic timestamp;
typedef struct Model__storage_ {
uint32_t _has_storage_[1];
NSString *action;
NSString *content;
NSString *sender;
NSString *receiver;
NSString *extra;
NSString *title;
NSString *format;
int64_t id_p;
int64_t timestamp;
} Model__storage_;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = nil;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
{
.name = "id_p",
.dataTypeSpecific.className = NULL,
.number = MessageModel_FieldNumber_Id_p,
.hasIndex = 0,
.offset = (uint32_t)offsetof(Model__storage_, id_p),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeInt64,
},
{
.name = "action",
.dataTypeSpecific.className = NULL,
.number = MessageModel_FieldNumber_Action,
.hasIndex = 1,
.offset = (uint32_t)offsetof(Model__storage_, action),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
},
{
.name = "content",
.dataTypeSpecific.className = NULL,
.number = MessageModel_FieldNumber_Content,
.hasIndex = 2,
.offset = (uint32_t)offsetof(Model__storage_, content),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
},
{
.name = "sender",
.dataTypeSpecific.className = NULL,
.number = MessageModel_FieldNumber_Sender,
.hasIndex = 3,
.offset = (uint32_t)offsetof(Model__storage_, sender),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
},
{
.name = "receiver",
.dataTypeSpecific.className = NULL,
.number = MessageModel_FieldNumber_Receiver,
.hasIndex = 4,
.offset = (uint32_t)offsetof(Model__storage_, receiver),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
},
{
.name = "extra",
.dataTypeSpecific.className = NULL,
.number = MessageModel_FieldNumber_Extra,
.hasIndex = 5,
.offset = (uint32_t)offsetof(Model__storage_, extra),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
},
{
.name = "title",
.dataTypeSpecific.className = NULL,
.number = MessageModel_FieldNumber_Title,
.hasIndex = 6,
.offset = (uint32_t)offsetof(Model__storage_, title),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
},
{
.name = "format",
.dataTypeSpecific.className = NULL,
.number = MessageModel_FieldNumber_Format,
.hasIndex = 7,
.offset = (uint32_t)offsetof(Model__storage_, format),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
},
{
.name = "timestamp",
.dataTypeSpecific.className = NULL,
.number = MessageModel_FieldNumber_Timestamp,
.hasIndex = 8,
.offset = (uint32_t)offsetof(Model__storage_, timestamp),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeInt64,
},
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[MessageModel class]
rootClass:[MessageRoot class]
file:MessageRoot_FileDescriptor()
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(Model__storage_)
flags:GPBDescriptorInitializationFlag_None];
#if defined(DEBUG) && DEBUG
NSAssert(descriptor == nil, @"Startup recursed!");
#endif // DEBUG
descriptor = localDescriptor;
}
return descriptor;
}
@end
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)

View File

@ -0,0 +1,79 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: ReplyBody.proto
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <Protobuf/GPBProtocolBuffers.h>
#else
#import "GPBProtocolBuffers.h"
#endif
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - ReplyBodyRoot
/**
* Exposes the extension registry for this file.
*
* The base class provides:
* @code
* + (GPBExtensionRegistry *)extensionRegistry;
* @endcode
* which is a @c GPBExtensionRegistry that includes all the extensions defined by
* this file and all files that it depends on.
**/
@interface ReplyBodyRoot : GPBRootObject
@end
#pragma mark - Model
typedef GPB_ENUM(ReplyBodyModel_FieldNumber) {
ReplyBodyModel_FieldNumber_Key = 1,
ReplyBodyModel_FieldNumber_Code = 2,
ReplyBodyModel_FieldNumber_Message = 3,
ReplyBodyModel_FieldNumber_Timestamp = 4,
ReplyBodyModel_FieldNumber_Data_p = 5,
};
@interface ReplyBodyModel : GPBMessage
@property(nonatomic, readwrite, copy, null_resettable) NSString *key;
@property(nonatomic, readwrite, copy, null_resettable) NSString *code;
@property(nonatomic, readwrite, copy, null_resettable) NSString *message;
@property(nonatomic, readwrite) int64_t timestamp;
@property(nonatomic, readwrite, strong, null_resettable) NSMutableDictionary<NSString*, NSString*> *data_p;
/** The number of items in @c data_p without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger data_p_Count;
@end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)

View File

@ -0,0 +1,137 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: ReplyBody.proto
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <Protobuf/GPBProtocolBuffers_RuntimeSupport.h>
#else
#import "GPBProtocolBuffers_RuntimeSupport.h"
#endif
#import "ReplyBody.pbobjc.h"
// @@protoc_insertion_point(imports)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma mark - ReplyBodyRoot
@implementation ReplyBodyRoot
// No extensions in the file and no imports, so no need to generate
// +extensionRegistry.
@end
#pragma mark - ReplyBodyRoot_FileDescriptor
static GPBFileDescriptor *ReplyBodyRoot_FileDescriptor(void) {
// This is called by +initialize so there is no need to worry
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@""
syntax:GPBFileSyntaxProto3];
}
return descriptor;
}
#pragma mark - Model
@implementation ReplyBodyModel
@dynamic key;
@dynamic code;
@dynamic message;
@dynamic timestamp;
@dynamic data_p, data_p_Count;
typedef struct Model__storage_ {
uint32_t _has_storage_[1];
NSString *key;
NSString *code;
NSString *message;
NSMutableDictionary *data_p;
int64_t timestamp;
} Model__storage_;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = nil;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
{
.name = "key",
.dataTypeSpecific.className = NULL,
.number = ReplyBodyModel_FieldNumber_Key,
.hasIndex = 0,
.offset = (uint32_t)offsetof(Model__storage_, key),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
},
{
.name = "code",
.dataTypeSpecific.className = NULL,
.number = ReplyBodyModel_FieldNumber_Code,
.hasIndex = 1,
.offset = (uint32_t)offsetof(Model__storage_, code),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
},
{
.name = "message",
.dataTypeSpecific.className = NULL,
.number = ReplyBodyModel_FieldNumber_Message,
.hasIndex = 2,
.offset = (uint32_t)offsetof(Model__storage_, message),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
},
{
.name = "timestamp",
.dataTypeSpecific.className = NULL,
.number = ReplyBodyModel_FieldNumber_Timestamp,
.hasIndex = 3,
.offset = (uint32_t)offsetof(Model__storage_, timestamp),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeInt64,
},
{
.name = "data_p",
.dataTypeSpecific.className = NULL,
.number = ReplyBodyModel_FieldNumber_Data_p,
.hasIndex = GPBNoHasBit,
.offset = (uint32_t)offsetof(Model__storage_, data_p),
.flags = GPBFieldMapKeyString,
.dataType = GPBDataTypeString,
},
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[ReplyBodyModel class]
rootClass:[ReplyBodyRoot class]
file:ReplyBodyRoot_FileDescriptor()
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(Model__storage_)
flags:GPBDescriptorInitializationFlag_None];
#if defined(DEBUG) && DEBUG
NSAssert(descriptor == nil, @"Startup recursed!");
#endif // DEBUG
descriptor = localDescriptor;
}
return descriptor;
}
@end
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)

View File

@ -0,0 +1,73 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: SentBody.proto
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <Protobuf/GPBProtocolBuffers.h>
#else
#import "GPBProtocolBuffers.h"
#endif
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
#pragma mark - SentBodyRoot
/**
* Exposes the extension registry for this file.
*
* The base class provides:
* @code
* + (GPBExtensionRegistry *)extensionRegistry;
* @endcode
* which is a @c GPBExtensionRegistry that includes all the extensions defined by
* this file and all files that it depends on.
**/
@interface SentBodyRoot : GPBRootObject
@end
#pragma mark - Model
typedef GPB_ENUM(Model_FieldNumber) {
Model_FieldNumber_Key = 1,
Model_FieldNumber_Timestamp = 2,
Model_FieldNumber_Data_p = 3,
};
@interface SentBodyModel : GPBMessage
@property(nonatomic, readwrite, copy, null_resettable) NSString *key;
@property(nonatomic, readwrite) int64_t timestamp;
@property(nonatomic, readwrite, strong, null_resettable) NSMutableDictionary<NSString*, NSString*> *data_p;
/** The number of items in @c data_p without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger data_p_Count;
@end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)

View File

@ -0,0 +1,118 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: SentBody.proto
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <Protobuf/GPBProtocolBuffers_RuntimeSupport.h>
#else
#import "GPBProtocolBuffers_RuntimeSupport.h"
#endif
#import "SentBody.pbobjc.h"
// @@protoc_insertion_point(imports)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma mark - SentBodyRoot
@implementation SentBodyRoot
// No extensions in the file and no imports, so no need to generate
// +extensionRegistry.
@end
#pragma mark - SentBodyRoot_FileDescriptor
static GPBFileDescriptor *SentBodyRoot_FileDescriptor(void) {
// This is called by +initialize so there is no need to worry
// about thread safety of the singleton.
static GPBFileDescriptor *descriptor = NULL;
if (!descriptor) {
GPB_DEBUG_CHECK_RUNTIME_VERSIONS();
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@""
syntax:GPBFileSyntaxProto3];
}
return descriptor;
}
#pragma mark - Model
@implementation SentBodyModel
@dynamic key;
@dynamic timestamp;
@dynamic data_p, data_p_Count;
typedef struct Model__storage_ {
uint32_t _has_storage_[1];
NSString *key;
NSMutableDictionary *data_p;
int64_t timestamp;
} Model__storage_;
// This method is threadsafe because it is initially called
// in +initialize for each subclass.
+ (GPBDescriptor *)descriptor {
static GPBDescriptor *descriptor = nil;
if (!descriptor) {
static GPBMessageFieldDescription fields[] = {
{
.name = "key",
.dataTypeSpecific.className = NULL,
.number = Model_FieldNumber_Key,
.hasIndex = 0,
.offset = (uint32_t)offsetof(Model__storage_, key),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeString,
},
{
.name = "timestamp",
.dataTypeSpecific.className = NULL,
.number = Model_FieldNumber_Timestamp,
.hasIndex = 1,
.offset = (uint32_t)offsetof(Model__storage_, timestamp),
.flags = GPBFieldOptional,
.dataType = GPBDataTypeInt64,
},
{
.name = "data_p",
.dataTypeSpecific.className = NULL,
.number = Model_FieldNumber_Data_p,
.hasIndex = GPBNoHasBit,
.offset = (uint32_t)offsetof(Model__storage_, data_p),
.flags = GPBFieldMapKeyString,
.dataType = GPBDataTypeString,
},
};
GPBDescriptor *localDescriptor =
[GPBDescriptor allocDescriptorForClass:[SentBodyModel class]
rootClass:[SentBodyRoot class]
file:SentBodyRoot_FileDescriptor()
fields:fields
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
storageSize:sizeof(Model__storage_)
flags:GPBDescriptorInitializationFlag_None];
#if defined(DEBUG) && DEBUG
NSAssert(descriptor == nil, @"Startup recursed!");
#endif // DEBUG
descriptor = localDescriptor;
}
return descriptor;
}
@end
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)

View File

@ -0,0 +1,21 @@
//
// CIMWeakProxy.h
// CIMKit
//
// Created by Chentao on 2022/9/14.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface CIMWeakProxy : NSProxy
@property (weak, readonly, nullable, nonatomic) id target;
- (nonnull instancetype)initWithTarget:(nonnull id)target;
+ (nonnull instancetype)proxyWithTarget:(nonnull id)target;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,79 @@
//
// CIMWeakProxy.m
// CIMKit
//
// Created by Chentao on 2022/9/14.
//
#import "CIMWeakProxy.h"
@implementation CIMWeakProxy
- (instancetype)initWithTarget:(id)target {
_target = target;
return self;
}
+ (instancetype)proxyWithTarget:(id)target {
return [[CIMWeakProxy alloc] initWithTarget:target];
}
- (id)forwardingTargetForSelector:(SEL)selector {
return _target;
}
- (void)forwardInvocation:(NSInvocation *)invocation {
void *null = NULL;
[invocation setReturnValue:&null];
}
- (NSMethodSignature *)methodSignatureForSelector:(SEL)selector {
return [NSObject instanceMethodSignatureForSelector:@selector(init)];
}
- (BOOL)respondsToSelector:(SEL)aSelector {
return [_target respondsToSelector:aSelector];
}
- (BOOL)isEqual:(id)object {
return [_target isEqual:object];
}
- (NSUInteger)hash {
return [_target hash];
}
- (Class)superclass {
return [_target superclass];
}
- (Class)class {
return [_target class];
}
- (BOOL)isKindOfClass:(Class)aClass {
return [_target isKindOfClass:aClass];
}
- (BOOL)isMemberOfClass:(Class)aClass {
return [_target isMemberOfClass:aClass];
}
- (BOOL)conformsToProtocol:(Protocol *)aProtocol {
return [_target conformsToProtocol:aProtocol];
}
- (BOOL)isProxy {
return YES;
}
- (NSString *)description {
return [_target description];
}
- (NSString *)debugDescription {
return [_target debugDescription];
}
@end

View File

@ -0,0 +1,33 @@
//
// KCLDataReader.h
// TeachingClient
//
// Created by Chentao on 2017/4/27.
// Copyright © 2017年 Chentao. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface KCLDataReader : NSObject
@property (nonatomic, assign) uint64_t poz;
@property (nonatomic, strong, readonly) NSData *data;
+ (instancetype)readerWithData:(NSData *)data;
- (instancetype)initWithData:(NSData *)data;
- (NSData *)readBytes:(uint64_t)len;
- (int32_t)readInt32;
- (int64_t)readInt64;
- (int16_t)readInt16;
- (uint32_t)readUInt32;
- (uint64_t)readUInt64;
- (uint16_t)readUInt16;
- (char)readByte;
- (BOOL)readBool;
- (NSString *)readString;
- (NSData *)readPrefixedBytes;
- (float)readFloat;
- (double)readDouble;
@end

View File

@ -0,0 +1,123 @@
//
// KCLDataReader.m
// TeachingClient
//
// Created by Chentao on 2017/4/27.
// Copyright © 2017 Chentao. All rights reserved.
//
#import "KCLDataReader.h"
@implementation KCLDataReader {
char *_pointer;
}
+ (instancetype)readerWithData:(NSData *)data {
return [[KCLDataReader alloc] initWithData:data];
}
- (instancetype)initWithData:(NSData *)data {
self = [super init];
if (!self || !data) {
return nil;
}
_data = data;
_pointer = (char *)data.bytes;
return self;
}
- (NSData *)readBytes:(uint64_t)len {
if (!len) {
return nil;
}
NSData *data = [_data subdataWithRange:NSMakeRange(_poz, len)];
_poz += len;
return data;
}
- (NSData *)readPrefixedBytes {
uint32_t len = [self readUInt32];
return [self readBytes:len];
}
- (int32_t)readInt32 {
char *ptr = _pointer + _poz;
_poz += sizeof(int32_t);
return *(int32_t *)ptr;
}
- (int64_t)readInt64 {
char *ptr = _pointer + _poz;
_poz += sizeof(int64_t);
return *(int64_t *)ptr;
}
- (int16_t)readInt16 {
char *ptr = _pointer + _poz;
_poz += sizeof(int16_t);
return *(int16_t *)ptr;
}
- (uint32_t)readUInt32 {
char *ptr = _pointer + _poz;
_poz += sizeof(uint32_t);
return *(uint32_t *)ptr;
}
- (uint64_t)readUInt64 {
char *ptr = _pointer + _poz;
_poz += sizeof(uint64_t);
return *(uint64_t *)ptr;
}
- (uint16_t)readUInt16 {
char *ptr = _pointer + _poz;
_poz += sizeof(uint16_t);
return *(uint16_t *)ptr;
}
- (char)readByte {
char *ptr = _pointer + _poz;
_poz += sizeof(char);
return *(char *)ptr;
}
- (BOOL)readBool {
char *ptr = _pointer + _poz;
_poz += sizeof(BOOL);
return *(BOOL *)ptr;
}
- (float)readFloat {
char *ptr = _pointer + _poz;
_poz += sizeof(float);
return *(float *)ptr;
}
- (double)readDouble {
char *ptr = _pointer + _poz;
_poz += sizeof(double);
return *(double *)ptr;
}
- (NSString *)readString {
NSData *data = [self readPrefixedBytes];
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
}
@end

View File

@ -0,0 +1,34 @@
//
// KCLDataWriter.h
// TeachingClient
//
// Created by Chentao on 2017/4/27.
// Copyright © 2017年 Chentao. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface KCLDataWriter : NSObject
@property (nonatomic, strong, readonly) NSMutableData *data;
+ (instancetype)writerWithData:(NSMutableData *)data;
- (instancetype)initWithData:(NSMutableData *)data;
- (void)writeBytes:(NSData *)bytes;
- (void)writeBytes:(const char *)rawBytes length:(uint32_t)length;
- (void)writePrefixedBytes:(NSData *)data;
- (void)writeInt32:(int32_t)value;
- (void)writeInt64:(int64_t)value;
- (void)writeInt16:(int16_t)value;
- (void)writeUInt32:(uint32_t)value;
- (void)writeUInt64:(uint64_t)value;
- (void)writeUInt16:(uint16_t)value;
- (void)writeByte:(char)byte;
- (void)writeBool:(BOOL)value;
- (void)writeString:(NSString *)str;
- (void)writeFloat:(float)value;
- (void)writeDouble:(double)value;
@end

View File

@ -0,0 +1,90 @@
//
// KCLDataWriter.m
// TeachingClient
//
// Created by Chentao on 2017/4/27.
// Copyright © 2017 Chentao. All rights reserved.
//
#import "KCLDataWriter.h"
@implementation KCLDataWriter
+ (instancetype)writerWithData:(NSMutableData *)data {
return [[KCLDataWriter alloc] initWithData:data];
}
- (instancetype)initWithData:(NSMutableData *)data {
self = [super init];
if (!self || !data) {
return nil;
}
_data = data;
return self;
}
- (void)writeBytes:(NSData *)bytes {
if (bytes.length) {
[_data appendData:bytes];
}
}
- (void)writeBytes:(const char *)rawBytes length:(uint32_t)length {
if (length) {
[_data appendBytes:rawBytes length:length];
}
}
- (void)writePrefixedBytes:(NSData *)data {
[self writeUInt32:(uint32_t)data.length];
[self writeBytes:data];
}
- (void)writeInt32:(int32_t)value {
[self writeBytes:(const char *)&value length:sizeof(int32_t)];
}
- (void)writeInt64:(int64_t)value {
[self writeBytes:(const char *)&value length:sizeof(int64_t)];
}
- (void)writeInt16:(int16_t)value {
[self writeBytes:(const char *)&value length:sizeof(int16_t)];
}
- (void)writeUInt32:(uint32_t)value {
[self writeBytes:(const char *)&value length:sizeof(uint32_t)];
}
- (void)writeUInt64:(uint64_t)value {
[self writeBytes:(const char *)&value length:sizeof(uint64_t)];
}
- (void)writeUInt16:(uint16_t)value {
[self writeBytes:(const char *)&value length:sizeof(uint16_t)];
}
- (void)writeByte:(char)byte {
[self writeBytes:(const char *)&byte length:sizeof(char)];
}
- (void)writeBool:(BOOL)value {
[self writeByte:value ? 1 : 0];
}
- (void)writeString:(NSString *)str {
[self writePrefixedBytes:[str dataUsingEncoding:NSUTF8StringEncoding]];
}
- (void)writeFloat:(float)value {
[self writeBytes:(const char *)&value length:sizeof(float)];
}
- (void)writeDouble:(double)value {
[self writeBytes:(const char *)&value length:sizeof(double)];
}
@end

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
</dict>
</dict>
</plist>

View File

@ -0,0 +1,15 @@
//
// SceneDelegate.h
// CIMKit
//
// Created by Chentao on 2022/8/31.
//
#import <UIKit/UIKit.h>
@interface SceneDelegate : UIResponder <UIWindowSceneDelegate>
@property (strong, nonatomic) UIWindow * window;
@end

View File

@ -0,0 +1,57 @@
//
// SceneDelegate.m
// CIMKit
//
// Created by Chentao on 2022/8/31.
//
#import "SceneDelegate.h"
@interface SceneDelegate ()
@end
@implementation SceneDelegate
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
}
- (void)sceneDidDisconnect:(UIScene *)scene {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
}
- (void)sceneDidBecomeActive:(UIScene *)scene {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}
- (void)sceneWillResignActive:(UIScene *)scene {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
}
- (void)sceneWillEnterForeground:(UIScene *)scene {
// Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background.
}
- (void)sceneDidEnterBackground:(UIScene *)scene {
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
}
@end

View File

@ -0,0 +1,14 @@
//
// ViewController.h
// CIMKit
//
// Created by Chentao on 2022/8/31.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@end

View File

@ -0,0 +1,106 @@
//
// ViewController.m
// CIMKit
//
// Created by Chentao on 2022/8/31.
//
#import "ViewController.h"
#import "CIMService.h"
@interface ViewController ()<CIMConnectionObserver, CIMPeerMessageObserver>
@property (nonatomic, strong) UIButton *addObserverButton;
@property (nonatomic, strong) UIButton *removeObserverButton;
@property (nonatomic, strong) UIButton *connectButton;
@property (nonatomic, strong) UIButton *closeButton;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[[CIMService instance] configHost:@"120.53.221.43" onPort:23456];
self.addObserverButton = [[UIButton alloc] initWithFrame:CGRectMake(50, 100, 150, 50)];
self.addObserverButton.backgroundColor = [UIColor grayColor];
[self.addObserverButton addTarget:self action:@selector(addObserverButtonHandler) forControlEvents:UIControlEventTouchUpInside];
[self.addObserverButton setTitle:@"addObserver" forState:UIControlStateNormal];
[self.view addSubview:self.addObserverButton];
self.removeObserverButton = [[UIButton alloc] initWithFrame:CGRectMake(220, 100, 150, 50)];
self.removeObserverButton.backgroundColor = [UIColor grayColor];
[self.removeObserverButton addTarget:self action:@selector(removeObserverButtonHandler) forControlEvents:UIControlEventTouchUpInside];
[self.removeObserverButton setTitle:@"removeObserver" forState:UIControlStateNormal];
[self.view addSubview:self.removeObserverButton];
self.connectButton = [[UIButton alloc] initWithFrame:CGRectMake(50, 170, 150, 50)];
self.connectButton.backgroundColor = [UIColor grayColor];
[self.connectButton addTarget:self action:@selector(connectButtonHandler) forControlEvents:UIControlEventTouchUpInside];
[self.connectButton setTitle:@"connec" forState:UIControlStateNormal];
[self.view addSubview:self.connectButton];
self.closeButton = [[UIButton alloc] initWithFrame:CGRectMake(220, 170, 150, 50)];
self.closeButton.backgroundColor = [UIColor grayColor];
[self.closeButton addTarget:self action:@selector(closeButtonHandler) forControlEvents:UIControlEventTouchUpInside];
[self.closeButton setTitle:@"close" forState:UIControlStateNormal];
[self.view addSubview:self.closeButton];
}
- (void)addObserverButtonHandler {
[[CIMService instance] addConnectionObserver:self];
[[CIMService instance] addMessageObserver:self];
}
- (void)removeObserverButtonHandler {
[[CIMService instance] removeConnectionObserver:self];
[[CIMService instance] removeMessageObserver:self];
}
- (void)connectButtonHandler {
[[CIMService instance] connection];
}
- (void)closeButtonHandler {
[[CIMService instance] disconnect];
}
#pragma mark - CIMConnectionObserver
- (void)cimDidBindUserSuccess:(BOOL)bindSuccess {
NSLog(@"%s",__FUNCTION__);
}
- (void)cimDidConnectSuccess {
[[CIMService instance] bindUserId:@"2222"];
NSLog(@"%s",__FUNCTION__);
}
- (void)cimDidReconnection:(NSInteger)reconnectionCount {
NSLog(@"reconnection count:%@", @(reconnectionCount));
}
- (void)cimDidConnectClose {
NSLog(@"%s",__FUNCTION__);
}
- (void)cimDidConnectError:(NSError *_Nullable)error {
NSLog(@"%s",__FUNCTION__);
}
#pragma mark - CIMPeerMessageObserver
- (void)cimHandleMessage:(CIMMessageModel *_Nonnull)msg {
NSLog(@"%s",__FUNCTION__);
}
- (void)cimHandleMessageError:(NSData *_Nonnull)data {
NSLog(@"%s",__FUNCTION__);
}
@end

View File

@ -0,0 +1,18 @@
//
// main.m
// CIMKit
//
// Created by Chentao on 2022/8/31.
//
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[]) {
NSString * appDelegateClassName;
@autoreleasepool {
// Setup code that might create autoreleased objects goes here.
appDelegateClassName = NSStringFromClass([AppDelegate class]);
}
return UIApplicationMain(argc, argv, nil, appDelegateClassName);
}

View File

@ -0,0 +1,13 @@
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'CIMKit' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for CIMKit
pod 'Protobuf', '~> 3.21.5'
pod "CocoaAsyncSocket", '~> 7.6.5'
end