ObjIRC  Diff

Differences From Artifact [12ead9fa2b]:

To Artifact [6579a2f540]:


34
35
36
37
38
39
40

41
42
43
44
45
46
47
48
49
50
51
52
53
54

55
56
57
58
59
60
61
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63







+














+








#import <ObjFW/macros.h>

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

@implementation IRCConnection
@synthesize socketClass = _socketClass;
@synthesize server = _server, port = _port;
@synthesize nickname = _nickname, username = _username, realname = _realname;
@synthesize delegate = _delegate, socket = _socket;

+ (instancetype)connection
{
	return [[[self alloc] init] autorelease];
}

- init
{
	self = [super init];

	@try {
		_socketClass = [OFTCPSocket class];
		_channels = [[OFMutableDictionary alloc] init];
		_port = 6667;
	} @catch (id e) {
		[self release];
		@throw e;
	}

77
78
79
80
81
82
83





84

85
86
87
88
89
90
91
79
80
81
82
83
84
85
86
87
88
89
90

91
92
93
94
95
96
97
98







+
+
+
+
+
-
+







- (void)connect
{
	void *pool = objc_autoreleasePoolPush();

	if (_socket != nil)
		@throw [OFAlreadyConnectedException exception];

	_socket = [[_socketClass alloc] init];
	if ([_delegate respondsToSelector:
	    @selector(connection:didCreateSocket:)])
		[_delegate connection: self
		      didCreateSocket: _socket];
	_socket = [[OFTCPSocket alloc] init];

	[_socket connectToHost: _server
			  port: _port];

	[self sendLineWithFormat: @"NICK %@", _nickname];
	[self sendLineWithFormat: @"USER %@ * 0 :%@", _username, _realname];

	objc_autoreleasePoolPop(pool);