BLUE
PHP 7.4.33
Path:
/var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/react-native/React/Inspector
Run
Logout
Edit File
Size: 3.00 KB
Close
/var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/react-native/React/Inspector/RCTCxxInspectorWebSocketAdapter.mm
Text
Base64
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #import "RCTCxxInspectorWebSocketAdapter.h" #if RCT_DEV || RCT_REMOTE_PROFILE #import <React/RCTInspector.h> #import <React/RCTInspectorPackagerConnection.h> #import <React/RCTLog.h> #import <React/RCTUtils.h> #import <SocketRocket/SRWebSocket.h> #import <jsinspector-modern/InspectorPackagerConnection.h> #import <memory> using namespace facebook::react::jsinspector_modern; static const uint64_t MAX_CONNECTING_TIME_NS = 2 * 1000000000L; namespace { NSString *NSStringFromUTF8StringView(std::string_view view) { return [[NSString alloc] initWithBytes:(const char *)view.data() length:view.size() encoding:NSUTF8StringEncoding]; } } // namespace @interface RCTCxxInspectorWebSocketAdapter () <SRWebSocketDelegate> { std::weak_ptr<IWebSocketDelegate> _delegate; SRWebSocket *_webSocket; } @end @implementation RCTCxxInspectorWebSocketAdapter - (instancetype)initWithURL:(const std::string &)url delegate:(std::weak_ptr<IWebSocketDelegate>)delegate { if ((self = [super init])) { _delegate = delegate; _webSocket = [[SRWebSocket alloc] initWithURL:[NSURL URLWithString:NSStringFromUTF8StringView(url)]]; _webSocket.delegate = self; [_webSocket open]; uint64_t startTime = clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW); while ([_webSocket readyState] == SR_CONNECTING) { if ((clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW) - startTime) > MAX_CONNECTING_TIME_NS) { break; } } if ([_webSocket readyState] != SR_OPEN) { return nil; } } return self; } - (void)send:(std::string_view)message { __weak RCTCxxInspectorWebSocketAdapter *weakSelf = self; NSString *messageStr = NSStringFromUTF8StringView(message); dispatch_async(dispatch_get_main_queue(), ^{ RCTCxxInspectorWebSocketAdapter *strongSelf = weakSelf; if (strongSelf) { [strongSelf->_webSocket sendString:messageStr error:NULL]; } }); } - (void)close { [_webSocket closeWithCode:1000 reason:@"End of session"]; } - (void)webSocket:(__unused SRWebSocket *)webSocket didFailWithError:(NSError *)error { // NOTE: We are on the main queue here, per SRWebSocket's defaults. if (auto delegate = _delegate.lock()) { delegate->didFailWithError([error code], [error description].UTF8String); } } - (void)webSocket:(__unused SRWebSocket *)webSocket didReceiveMessageWithString:(NSString *)message { // NOTE: We are on the main queue here, per SRWebSocket's defaults. if (auto delegate = _delegate.lock()) { delegate->didReceiveMessage([message UTF8String]); } } - (void)webSocket:(__unused SRWebSocket *)webSocket didCloseWithCode:(__unused NSInteger)code reason:(__unused NSString *)reason wasClean:(__unused BOOL)wasClean { // NOTE: We are on the main queue here, per SRWebSocket's defaults. if (auto delegate = _delegate.lock()) { delegate->didClose(); } } @end #endif
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 9
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
RCTCxxInspectorPackagerConnection.h
443 B
lrw-r--r--
2025-03-28 11:04:41
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
RCTCxxInspectorPackagerConnection.mm
1.63 KB
lrw-r--r--
2025-03-28 11:04:43
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
RCTCxxInspectorPackagerConnectionDelegate.h
1.23 KB
lrw-r--r--
2025-03-28 11:04:41
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
RCTCxxInspectorPackagerConnectionDelegate.mm
1.37 KB
lrw-r--r--
2025-03-28 11:04:43
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
RCTCxxInspectorWebSocketAdapter.h
635 B
lrw-r--r--
2025-03-28 11:04:41
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
RCTCxxInspectorWebSocketAdapter.mm
3.00 KB
lrw-r--r--
2025-03-28 11:04:43
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
RCTInspector.h
867 B
lrw-r--r--
2025-03-28 11:04:41
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
RCTInspector.mm
3.29 KB
lrw-r--r--
2025-03-28 11:04:43
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
RCTInspectorPackagerConnection.h
737 B
lrw-r--r--
2025-03-28 11:04:41
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).