Overview
Comment: | Rename splitted to split. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
5e1d907b6ce138715487e34a8e3865bb |
User & Date: | js on 2011-09-09 16:50:54 |
Other Links: | manifest | tags |
Context
2011-09-09
| ||
16:53 | Revert "fix" for parsing JOIN as it broke stuff. check-in: 960f920c6d user: js tags: trunk | |
16:50 | Rename splitted to split. check-in: 5e1d907b6c user: js tags: trunk | |
16:46 | Add support for handling QUIT. check-in: 4e9e1552b6 user: js tags: trunk | |
Changes
Modified src/IRCConnection.m from [c0d4a5d2c9] to [df4362f571].
︙ | ︙ | |||
126 127 128 129 130 131 132 | [pool release]; } - (void)handleConnection { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFString *line; | | | < | | | | | | | | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 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 | [pool release]; } - (void)handleConnection { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFString *line; OFArray *split; for (;;) { @try { line = [sock readLine]; } @catch (OFInvalidEncodingException *e) { [e dealloc]; line = [sock readLineWithEncoding: OF_STRING_ENCODING_WINDOWS_1252]; } if (line == nil) break; if ([delegate respondsToSelector: @selector(connection:didReceiveLine:)]) [delegate connection: self didReceiveLine: line]; split = [line componentsSeparatedByString: @" "]; /* PING */ if (split.count == 2 && [split.firstObject isEqual: @"PING"]) { OFMutableString *s = [[line mutableCopy] autorelease]; [s replaceOccurrencesOfString: @"PING" withString: @"PONG"]; [self sendLine: s]; continue; } /* Connected */ if (split.count >= 4 && [[split objectAtIndex: 1] isEqual: @"001"]) { if ([delegate respondsToSelector: @selector(connectionWasEstablished:)]) [delegate connectionWasEstablished: self]; continue; } /* JOIN */ if (split.count == 3 && [[split objectAtIndex: 1] isEqual: @"JOIN"]) { OFString *who = [split objectAtIndex: 0]; OFString *where = [split objectAtIndex: 2]; IRCUser *user; IRCChannel *channel; who = [who substringWithRange: of_range(1, who.length - 1)]; user = [IRCUser IRCUserWithString: who]; |
︙ | ︙ | |||
198 199 200 201 202 203 204 | didSeeUser: user joinChannel: channel]; continue; } /* PART */ | | | | | | | | | | | < | | | | | | | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | didSeeUser: user joinChannel: channel]; continue; } /* PART */ if (split.count >= 3 && [[split objectAtIndex: 1] isEqual: @"PART"]) { OFString *who = [split objectAtIndex: 0]; OFString *where = [split objectAtIndex: 2]; IRCUser *user; IRCChannel *channel; OFString *reason = nil; size_t pos = who.length + 1 + [[split objectAtIndex: 1] length] + 1 + where.length; who = [who substringWithRange: of_range(1, who.length - 1)]; user = [IRCUser IRCUserWithString: who]; channel = [channels objectForKey: where]; if (split.count > 3) reason = [line substringWithRange: of_range(pos + 2, line.length - pos - 2)]; if ([delegate respondsToSelector: @selector(connection:didSeeUser:leaveChannel: withReason:)]) [delegate connection: self didSeeUser: user leaveChannel: channel withReason: reason]; continue; } /* QUIT */ if (split.count >= 2 && [[split objectAtIndex: 1] isEqual: @"QUIT"]) { OFString *who = [split objectAtIndex: 0]; IRCUser *user; OFString *reason = nil; size_t pos = who.length + 1 + [[split objectAtIndex: 1] length]; who = [who substringWithRange: of_range(1, who.length - 1)]; user = [IRCUser IRCUserWithString: who]; if (split.count > 2) reason = [line substringWithRange: of_range(pos + 2, line.length - pos - 2)]; if ([delegate respondsToSelector: @selector(connection:didSeeUserQuit:withReason:)]) [delegate connection: self didSeeUserQuit: user withReason: reason]; continue; } /* PRIVMSG */ if (split.count >= 4 && [[split objectAtIndex: 1] isEqual: @"PRIVMSG"]) { OFString *from = [split objectAtIndex: 0]; OFString *to = [split objectAtIndex: 2]; IRCUser *user; OFString *msg; size_t pos = from.length + 1 + [[split objectAtIndex: 1] length] + 1 + to.length; from = [from substringWithRange: of_range(1, from.length - 1)]; msg = [line substringWithRange: of_range(pos + 2, line.length - pos - 2)]; |
︙ | ︙ |