Doesn't crash now. Of course, there's still lots of problems.
[ITFoundation.git] / ShowcaseController.m
1 //
2 //  ShowcaseController.m
3 //  ITFoundation
4 //
5 //  Created by Alexander Strange on Fri Feb 14 2003.
6 //  Copyright (c) 2003 __MyCompanyName__. All rights reserved.
7 //
8
9 #import "ShowcaseController.h"
10 #import "ITInetSocket.h"
11
12 ITInetSocket *sock;
13
14 @implementation ShowcaseController
15 - (void)awakeFromNib
16 {
17     sock = [[ITInetSocket alloc] initWithDelegate:self];
18     NSLog(@"rawr?");
19     [sock connectToHost:@"irc.freenode.net" onPort:6667];
20 }
21
22 - (void) finishedConnecting:(ITInetSocket *)sender {
23
24 }
25
26 - (void) errorOccured:(ITInetSocketError)err during:(ITInetSocketState)state onSocket:(in ITInetSocket*)sender {NSLog(@"wtf");[sender retryConnection];}
27 - (void) dataReceived:(ITInetSocket *)sender
28 {
29 }
30
31 - (void) newDataAdded:(ITByteStream*)sender {
32     static int firstTime = YES;
33     NSString *ircini = @"USER m0nk3ys . . :Not Telling\r\nNICK ITFTest\r\n", *irc2 = @"JOIN #iThink\r\nPRIVMSG #iThink :w00t\r\nQUIT :!\r\n";
34     NSLog(@"Writing something");
35     NSData *d = [NSData dataWithBytes:[firstTime?ircini:irc2 cString] length:[firstTime?ircini:irc2 length]];
36     [sock->writePipe writeData:d];
37     NSLog(@"Reading something");
38     firstTime = NO;
39 }
40 @end