|
14 | 14 | // limitations under the License.
|
15 | 15 | //
|
16 | 16 |
|
17 |
| -#if !TARGET_OS_UIKITFORMAC |
18 |
| - |
19 | 17 | #import <React/RCTSRWebSocket.h>
|
20 | 18 |
|
21 | 19 | #import <Availability.h>
|
22 |
| -#import <Endian.h> |
23 | 20 |
|
24 | 21 | #import <Security/SecRandom.h>
|
25 | 22 |
|
@@ -580,7 +577,7 @@ - (void)closeWithCode:(NSInteger)code reason:(NSString *)reason
|
580 | 577 | NSMutableData *mutablePayload = [[NSMutableData alloc] initWithLength:sizeof(uint16_t) + maxMsgSize];
|
581 | 578 | NSData *payload = mutablePayload;
|
582 | 579 |
|
583 |
| - ((uint16_t *)mutablePayload.mutableBytes)[0] = EndianU16_BtoN(code); |
| 580 | + ((uint16_t *)mutablePayload.mutableBytes)[0] = NSSwapBigShortToHost(code); |
584 | 581 |
|
585 | 582 | if (reason) {
|
586 | 583 | NSRange remainingRange = {0};
|
@@ -749,7 +746,7 @@ - (void)handleCloseWithData:(NSData *)data
|
749 | 746 | return;
|
750 | 747 | } else if (dataSize >= 2) {
|
751 | 748 | [data getBytes:&closeCode length:sizeof(closeCode)];
|
752 |
| - _closeCode = EndianU16_BtoN(closeCode); |
| 749 | + _closeCode = NSSwapBigShortToHost(closeCode); |
753 | 750 | if (!closeCodeIsValid(_closeCode)) {
|
754 | 751 | [self _closeWithProtocolError:[NSString stringWithFormat:@"Cannot have close code of %d", _closeCode]];
|
755 | 752 | return;
|
@@ -972,12 +969,12 @@ - (void)_readFrameContinue
|
972 | 969 |
|
973 | 970 | if (header.payload_length == 126) {
|
974 | 971 | assert(mapped_size >= sizeof(uint16_t));
|
975 |
| - uint16_t newLen = EndianU16_BtoN(*(uint16_t *)(mapped_buffer)); |
| 972 | + uint16_t newLen = NSSwapBigShortToHost(*(uint16_t *)(mapped_buffer)); |
976 | 973 | header.payload_length = newLen;
|
977 | 974 | offset += sizeof(uint16_t);
|
978 | 975 | } else if (header.payload_length == 127) {
|
979 | 976 | assert(mapped_size >= sizeof(uint64_t));
|
980 |
| - header.payload_length = EndianU64_BtoN(*(uint64_t *)(mapped_buffer)); |
| 977 | + header.payload_length = NSSwapBigLongLongToHost(*(uint64_t *)(mapped_buffer)); |
981 | 978 | offset += sizeof(uint64_t);
|
982 | 979 | } else {
|
983 | 980 | assert(header.payload_length < 126 && header.payload_length >= 0);
|
@@ -1264,11 +1261,11 @@ - (void)_sendFrameWithOpcode:(RCTSROpCode)opcode data:(NSData *)data
|
1264 | 1261 | frame_buffer[1] |= payloadLength;
|
1265 | 1262 | } else if (payloadLength <= UINT16_MAX) {
|
1266 | 1263 | frame_buffer[1] |= 126;
|
1267 |
| - *((uint16_t *)(frame_buffer + frame_buffer_size)) = EndianU16_BtoN((uint16_t)payloadLength); |
| 1264 | + *((uint16_t *)(frame_buffer + frame_buffer_size)) = NSSwapBigShortToHost((uint16_t)payloadLength); |
1268 | 1265 | frame_buffer_size += sizeof(uint16_t);
|
1269 | 1266 | } else {
|
1270 | 1267 | frame_buffer[1] |= 127;
|
1271 |
| - *((uint64_t *)(frame_buffer + frame_buffer_size)) = EndianU64_BtoN((uint64_t)payloadLength); |
| 1268 | + *((uint64_t *)(frame_buffer + frame_buffer_size)) = NSSwapBigLongLongToHost((uint64_t)payloadLength); |
1272 | 1269 | frame_buffer_size += sizeof(uint64_t);
|
1273 | 1270 | }
|
1274 | 1271 |
|
@@ -1637,5 +1634,3 @@ - (NSRunLoop *)runLoop
|
1637 | 1634 | }
|
1638 | 1635 |
|
1639 | 1636 | @end
|
1640 |
| - |
1641 |
| -#endif |
0 commit comments