ObjFW
Loading...
Searching...
No Matches
OFRunLoop+Private.h
1/*
2 * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3 *
4 * All rights reserved.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License version 3.0 only,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * version 3.0 for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * version 3.0 along with this program. If not, see
17 * <https://www.gnu.org/licenses/>.
18 */
19
20#import "OFRunLoop.h"
21#import "OFStream.h"
22#ifdef OF_HAVE_SOCKETS
23# import "OFDatagramSocket.h"
25# import "OFStreamSocket.h"
26#endif
27
28OF_ASSUME_NONNULL_BEGIN
29
30#ifdef OF_HAVE_SOCKETS
31@protocol OFRunLoopConnectDelegate <OFObject>
32- (void)of_socketDidConnect: (id)socket
33 exception: (nullable id)exception;
34- (id)of_connectionFailedExceptionForErrNo: (int)errNo;
35@end
36#endif
37
38OF_DIRECT_MEMBERS
39@interface OFRunLoop ()
40+ (void)of_setMainRunLoop: (OFRunLoop *)runLoop;
41#ifdef OF_HAVE_SOCKETS
42+ (void)of_addAsyncReadForStream: (OFStream <OFReadyForReadingObserving> *)
43 stream
44 buffer: (void *)buffer
45 length: (size_t)length
46 mode: (OFRunLoopMode)mode
47# ifdef OF_HAVE_BLOCKS
48 block: (nullable OFStreamAsyncReadBlock)block
49# endif
50 delegate: (nullable id <OFStreamDelegate>)delegate;
51+ (void)of_addAsyncReadForStream: (OFStream <OFReadyForReadingObserving> *)
52 stream
53 buffer: (void *)buffer
54 exactLength: (size_t)length
55 mode: (OFRunLoopMode)mode
56# ifdef OF_HAVE_BLOCKS
57 block: (nullable OFStreamAsyncReadBlock)block
58# endif
59 delegate: (nullable id <OFStreamDelegate>)delegate;
60+ (void)of_addAsyncReadLineForStream: (OFStream <OFReadyForReadingObserving> *)
61 stream
62 encoding: (OFStringEncoding)encoding
63 mode: (OFRunLoopMode)mode
64# ifdef OF_HAVE_BLOCKS
65 block: (nullable OFStreamAsyncReadLineBlock)block
66# endif
67 delegate: (nullable id <OFStreamDelegate>)delegate;
68+ (void)of_addAsyncWriteForStream: (OFStream <OFReadyForWritingObserving> *)
69 stream
70 data: (OFData *)data
71 mode: (OFRunLoopMode)mode
72# ifdef OF_HAVE_BLOCKS
73 block: (nullable OFStreamAsyncWriteDataBlock)block
74# endif
75 delegate: (nullable id <OFStreamDelegate>)delegate;
76+ (void)of_addAsyncWriteForStream: (OFStream <OFReadyForWritingObserving> *)
77 stream
78 string: (OFString *)string
79 encoding: (OFStringEncoding)encoding
80 mode: (OFRunLoopMode)mode
81# ifdef OF_HAVE_BLOCKS
82 block: (nullable OFStreamAsyncWriteStringBlock)block
83# endif
84 delegate: (nullable id <OFStreamDelegate>)delegate;
85# if !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
86+ (void)of_addAsyncConnectForSocket: (id)socket
87 mode: (OFRunLoopMode)mode
88 delegate: (id <OFRunLoopConnectDelegate>)delegate;
89# endif
90+ (void)of_addAsyncAcceptForSocket: (id)socket
91 mode: (OFRunLoopMode)mode
92 block: (nullable id)block
93 delegate: (nullable id)delegate;
94+ (void)of_addAsyncReceiveForDatagramSocket: (OFDatagramSocket *)socket
95 buffer: (void *)buffer
96 length: (size_t)length
97 mode: (OFRunLoopMode)mode
98# ifdef OF_HAVE_BLOCKS
99 block: (nullable OFDatagramSocketAsyncReceiveBlock)block
100# endif
101 delegate: (nullable id <OFDatagramSocketDelegate>) delegate;
102+ (void)of_addAsyncSendForDatagramSocket: (OFDatagramSocket *)socket
103 data: (OFData *)data
104 receiver: (const OFSocketAddress *)receiver
105 mode: (OFRunLoopMode)mode
106# ifdef OF_HAVE_BLOCKS
107 block: (nullable OFDatagramSocketAsyncSendDataBlock)block
108# endif
109 delegate: (nullable id <OFDatagramSocketDelegate>)delegate;
110+ (void)of_addAsyncReceiveForSequencedPacketSocket:
112 buffer: (void *)buffer
113 length: (size_t)length
114 mode: (OFRunLoopMode)mode
115# ifdef OF_HAVE_BLOCKS
116 block: (nullable OFSequencedPacketSocketAsyncReceiveBlock)block
117# endif
118 delegate: (nullable id <OFSequencedPacketSocketDelegate>) delegate;
119+ (void)of_addAsyncSendForSequencedPacketSocket:
121 data: (OFData *)data
122 mode: (OFRunLoopMode)mode
123# ifdef OF_HAVE_BLOCKS
124 block: (nullable OFSequencedPacketSocketAsyncSendDataBlock)block
125# endif
126 delegate: (nullable id <OFSequencedPacketSocketDelegate>)delegate;
127+ (void)of_cancelAsyncRequestsForObject: (id)object mode: (OFRunLoopMode)mode;
128#endif
129- (void)of_removeTimer: (OFTimer *)timer forMode: (OFRunLoopMode)mode;
130@end
131
132OF_ASSUME_NONNULL_END
OFData *(^ OFDatagramSocketAsyncSendDataBlock)(id exception)
A block which is called when a packet has been sent.
Definition OFDatagramSocket.h:52
bool(^ OFDatagramSocketAsyncReceiveBlock)(size_t length, const OFSocketAddress *sender, id exception)
A block which is called when a packet has been received.
Definition OFDatagramSocket.h:42
bool(^ OFSequencedPacketSocketAsyncReceiveBlock)(size_t length, id exception)
A block which is called when a packet has been received.
Definition OFSequencedPacketSocket.h:41
OFData *(^ OFSequencedPacketSocketAsyncSendDataBlock)(id exception)
A block which is called when a packet has been sent.
Definition OFSequencedPacketSocket.h:51
OFData *(^ OFStreamAsyncWriteDataBlock)(size_t bytesWritten, id exception)
A block which is called when data was written asynchronously to a stream.
Definition OFStream.h:79
bool(^ OFStreamAsyncReadBlock)(size_t length, id exception)
A block which is called when data was read asynchronously from a stream.
Definition OFStream.h:53
bool(^ OFStreamAsyncReadLineBlock)(OFString *line, id exception)
A block which is called when a line was read asynchronously from a stream.
Definition OFStream.h:65
OFString *(^ OFStreamAsyncWriteStringBlock)(size_t bytesWritten, id exception)
A block which is called when a string was written asynchronously to a stream.
Definition OFStream.h:93
OFStringEncoding
The encoding of a string.
Definition OFString.h:65
A class for storing constant strings using the @"" literal.
Definition OFConstantString.h:42
A class for storing arbitrary data in an array.
Definition OFData.h:46
A base class for datagram sockets.
Definition OFDatagramSocket.h:111
The root class for all other classes inside ObjFW.
Definition OFObject.h:692
A class providing a run loop for the application and its processes.
Definition OFRunLoop.h:66
A base class for sequenced packet sockets.
Definition OFSequencedPacketSocket.h:132
A base class for different types of streams.
Definition OFStream.h:192
A class for handling strings.
Definition OFString.h:139
A class for creating and firing timers.
Definition OFTimer.h:50
A struct which represents a host / port pair for a socket.
Definition OFSocket.h:186