facebookincubator /SocketRocket
A conforming Objective-C WebSocket client library.
★ 9,597⑂ 2,004👁 326⑃ 286● 403▤ 5
+0
日增长
9,597
stars
2,004
forks
326
watchers
286
prs
403
issues
5
releases
README
SocketRocket ![Platforms][platforms-svg] [![License][license-svg]][license-link] [![Podspec][podspec-svg]][podspec-link] [![Carthage Compatible][carthage-svg]](carthage-link) [![Build Status][build-status-svg]][build-status-link] A conforming WebSocket (RFC 6455) client library for iOS, macOS, tvOS and visionOS. Test results for SocketRocket here. You can compare to what modern browsers look like here. SocketRocket currently conforms to all core ~300 of Autobahn's fuzzing tests (aside from two UTF-8 ones where it is merely non-strict tests 6.4.2 and 6.4.4). Features/Design - TLS (wss) support, including self-signed certificates. - Seems to perform quite well. - Supports HTTP Proxies. - Supports IPv4/IPv6. - Supports SSL certificate pinning. - Sends ping and can process pong events. - Asynchronous and non-blocking. Most of the work is done on a background thread. - Supports iOS, macOS, tvOS. Installing There are a few options. Choose one, or just figure it out: - CocoaPods Add the following line to your Podfile: ruby pod 'SocketRocket' Run pod install, and you are all set. - Carthage Add the following line to your Cartfile: github "facebook/SocketRocket" Run carthage update, and you should now have the latest version of SocketRocket in your Carthage folder. - Using SocketRocket as a sub-project You can also include SocketRocket as a subproject inside of your application if you'd prefer, although we do not recommend this, as it will increase your indexing time significantly. To do so, just drag and drop the SocketRocket.xcodeproj file into your workspace. API SRWebSocket The Web Socket. Note: SRWebSocket will retain itself between -(void)open and when it closes, errors, or fails. This is similar to how NSURLConnection behaves (unlike NSURLConnection, SRWebSocket won't retain the delegate). Interface objective-c @interface SRWebSocket : NSObject // Make it with this - (instancetype)initWithURLRequest:(NSURLRequest )request; // Set this before opening @property (nonatomic, weak) id delegate; // Open with this - (void)open; // Close it with this - (void)close; // Send a Data - (void)sendData:(nullable NSData )data error:(NSError )error; // Send a UTF8 String - (void)sendString:(NSString )string error:(NSError )error; @end SRWebSocketDelegate You implement this objective-c @protocol SRWebSocketDelegate @optional - (void)webSocketDidOpen:(SRWebSocket )webSocket; - (void)webSocket:(SRWebSocket )webSocket didReceiveMessageWithString:(NSString )string; - (void)webSocket:(SRWebSocket )webSocket didReceiveMessageWithData:(NSData )data; - (void)webSocket:(SRWebSocket )webSocket didFailWithError:(NSError )error; - (void)webSocket:(SRWebSocket )webSocket didCloseWithCode:(NSInteger)code reason:(nullable NSString )reason wasClean:(BOOL)wasClean; @end Testing Included are setup scripts for the python testing environment. It comes packaged with vitualenv so all the dependencies are installed in
Top issues
#500Error ITMS-90056: Info.plist file is missing the required key: CFBundleVersion13 comments · 2017-01-23#648iOS 16 Xcode14 Thread Performance Checker: Thread running at QOS_CLASS_USER_INTERACTIVE waiting on a lower QoS thread running at QOS_CLASS_DEFAULT.12 comments · 2022-09-14#565Stream end encountered !!!10 comments · 2018-04-16#301CFNetwork -9800 error met when [SRWebSocket open]10 comments · 2015-10-22#479messages not received from socket rocket when app is in background9 comments · 2016-10-03#114Feature request. iOS devices. Work through http proxy9 comments · 2013-09-16#513Release new pod version: 0.6.08 comments · 2017-04-07#692SRSecurityPolicy.m:11:9 'SRPinningSecurityPolicy.h' file not found & 'SRDelegateController.h' file not found6 comments · 2024-09-30
Latest release
0.7.1 0.7.1 2024-08-31What's Changed Add visionOS support by @gabrieldonadel in https://github.com/facebookincubator/SocketRocket/pull/669 Replace usage of deprecated APIs, fix implicit nullability conversion. by @nlutsenko in https://github.com/facebookincubator/SocketRocket/pull/687 Full Changelog: https://github.com/facebookincubator/SocketRocket/compare/0.7.0...0.7.1