220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
+
|
@public
# ifdef OF_HAVE_BLOCKS
OFSCTPSocketAsyncSendDataBlock _block;
# endif
OFData *_data;
uint16_t _streamID;
uint32_t _PPID;
OFSCTPPacketFlags _flags;
}
@end
# endif
#endif
@implementation OFRunLoopState
- (instancetype)init
|
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
|
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
|
+
-
+
+
-
+
-
+
+
+
|
# ifdef OF_HAVE_SCTP
@implementation OFRunLoopSCTPReceiveQueueItem
- (bool)handleObject: (id)object
{
size_t length;
uint16_t streamID;
uint32_t PPID;
OFSCTPPacketFlags flags;
id exception = nil;
@try {
length = [object receiveIntoBuffer: _buffer
length: _length
streamID: &streamID
PPID: &PPID];
PPID: &PPID
flags: &flags];
} @catch (id e) {
length = 0;
exception = e;
}
# ifdef OF_HAVE_BLOCKS
if (_block != NULL)
return _block(length, streamID, PPID, exception);
return _block(length, streamID, PPID, flags, exception);
else {
# endif
if (![_delegate respondsToSelector: @selector(socket:
didReceiveIntoBuffer:length:streamID:PPID:exception:)])
didReceiveIntoBuffer:length:streamID:PPID:flags:
exception:)])
return false;
return [_delegate socket: object
didReceiveIntoBuffer: _buffer
length: length
streamID: streamID
PPID: PPID
flags: flags
exception: exception];
# ifdef OF_HAVE_BLOCKS
}
# endif
}
# ifdef OF_HAVE_BLOCKS
|
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
|
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
|
-
+
+
-
-
+
+
+
|
id exception = nil;
OFData *newData, *oldData;
@try {
[object sendBuffer: _data.items
length: _data.count * _data.itemSize
streamID: _streamID
PPID: _PPID];
PPID: _PPID
flags: _flags];
} @catch (id e) {
exception = e;
}
# ifdef OF_HAVE_BLOCKS
if (_block != NULL) {
newData = _block(exception);
if (newData == nil)
return false;
oldData = _data;
_data = [newData copy];
[oldData release];
return true;
} else {
# endif
if (![_delegate respondsToSelector:
@selector(socket:didSendData:streamID:PPID:exception:)])
if (![_delegate respondsToSelector: @selector(socket:
didSendData:streamID:PPID:flags:exception:)])
return false;
newData = [_delegate socket: object
didSendData: _data
streamID: _streamID
PPID: _PPID
flags: _flags
exception: exception];
if (newData == nil)
return false;
oldData = _data;
_data = [newData copy];
|
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
|
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
|
+
+
|
QUEUE_ITEM
}
+ (void)of_addAsyncSendForSCTPSocket: (OFSCTPSocket *)sock
data: (OFData *)data
streamID: (uint16_t)streamID
PPID: (uint32_t)PPID
flags: (OFSCTPPacketFlags)flags
mode: (OFRunLoopMode)mode
# ifdef OF_HAVE_BLOCKS
block: (OFSCTPSocketAsyncSendDataBlock)block
# endif
delegate: (id <OFSCTPSocketDelegate>)delegate
{
NEW_WRITE(OFRunLoopSCTPSendQueueItem, sock, mode)
queueItem->_delegate = [delegate retain];
# ifdef OF_HAVE_BLOCKS
queueItem->_block = [block copy];
# endif
queueItem->_data = [data copy];
queueItem->_streamID = streamID;
queueItem->_PPID = PPID;
queueItem->_flags = flags;
QUEUE_ITEM
}
# endif
# undef NEW_READ
# undef NEW_WRITE
# undef QUEUE_ITEM
|