ObjIRC  Check-in [e7f34ce8d0]

Overview
Comment:Use async I/O.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e7f34ce8d03e83a75b0da0471aafe0e84e139f0b2e4f5dde571bd6b5bdd07cbd
User & Date: js on 2012-10-17 20:18:31
Other Links: manifest | tags
Context
2012-10-30
19:07
Adjust to new async API. check-in: 0c43f5d8ca user: js tags: trunk
2012-10-17
20:18
Use async I/O. check-in: e7f34ce8d0 user: js tags: trunk
2012-03-21
10:53
Update URL in copyright. check-in: 58f1f2d5c5 user: js tags: trunk
Changes

Modified src/IRCChannel.m from [82f63b0a8e] to [16d8144689].

15
16
17
18
19
20
21


22
23
24
25
26
27
28
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30







+
+







 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import <ObjFW/OFString.h>

#import "IRCChannel.h"

@implementation IRCChannel
@synthesize name, users;

+ channelWithName: (OFString*)name

Modified src/IRCConnection.h from [ed10d07beb] to [13e6df650f].

106
107
108
109
110
111
112
113

114
115
106
107
108
109
110
111
112

113
114
115







-
+


	    toUser: (OFString*)user;
- (void)sendNotice: (OFString*)notice
	 toChannel: (IRCChannel*)channel;
- (void)kickUser: (OFString*)user
     fromChannel: (IRCChannel*)channel
      withReason: (OFString*)reason;
- (void)changeNicknameTo: (OFString*)nickname;
- (void)process;
- (void)processLine: (OFString*)line;
- (void)handleConnection;
@end

Modified src/IRCConnection.m from [e5ee986697] to [2f7ac026cf].

25
26
27
28
29
30
31


32
33
34
35
36
37
38
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40







+
+







#import <ObjFW/OFString.h>
#import <ObjFW/OFArray.h>
#import <ObjFW/OFMutableDictionary.h>
#import <ObjFW/OFTCPSocket.h>
#import <ObjFW/OFAutoreleasePool.h>

#import <ObjFW/OFInvalidEncodingException.h>

#import <ObjFW/macros.h>

#import "IRCConnection.h"
#import "IRCUser.h"
#import "IRCChannel.h"

@implementation IRCConnection
@synthesize server, port, nickname, username, realname, delegate, sock;
159
160
161
162
163
164
165
166

167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
161
162
163
164
165
166
167

168
169
170

171
172
173


















174
175
176
177
178
179
180







-
+


-



-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-







}

- (void)changeNicknameTo: (OFString*)nickname_
{
	[self sendLineWithFormat: @"NICK %@", nickname_];
}

- (void)process
- (void)processLine: (OFString*)line
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFString *line;
	OFArray *split;
	OFString *action = nil;

	if (sock.atEndOfStream) {
		if ([delegate respondsToSelector:
		    @selector(connectionWasClosed:)])
			[delegate connectionWasClosed: self];

		return;
	}

	@try {
		line = [sock tryReadLine];
	} @catch (OFInvalidEncodingException *e) {
		line = [sock tryReadLineWithEncoding:
		    OF_STRING_ENCODING_WINDOWS_1252];
	}

	if (line == nil)
		return;

	if ([delegate respondsToSelector:
	    @selector(connection:didReceiveLine:)])
		[delegate connection: self
		      didReceiveLine: line];

	split = [line componentsSeparatedByString: @" "];

497
498
499
500
501
502
503
504







505
506
507
508
































509
510
511
512
513
514
515
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494




495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533








+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







					    fromUser: user];
		}

		[pool release];
		return;
	}
}

-	  (BOOL)connection: (OFTCPSocket*)connection
    didReceiveISO88591Line: (OFString*)line
		 exception: (OFException*)exception
{
	if (line != nil) {
		[self processLine: line];
		[sock asyncReadLineWithTarget: self
- (void)handleConnection
{
	while (![sock isAtEndOfStream])
		[self process];
				     selector: @selector(connection:
						   didReceiveLine:
						   exception:)];
	}

	return NO;
}

- (BOOL)connection: (OFTCPSocket*)connection
    didReceiveLine: (OFString*)line
	 exception: (OFException*)exception
{
	if (line != nil) {
		[self processLine: line];
		return YES;
	}

	if ([exception isKindOfClass: [OFInvalidEncodingException class]])
		[sock asyncReadLineWithEncoding: OF_STRING_ENCODING_ISO_8859_1
					 target: self
				       selector: @selector(connection:
						     didReceiveISO88591Line:
						     exception:)];

	return NO;
}

- (void)handleConnection
{
	[sock asyncReadLineWithTarget: self
			     selector: @selector(connection:didReceiveLine:
					   exception:)];
}

- (void)dealloc
{
	[sock release];
	[server release];
	[nickname release];