author | Jens Alfke <jens@mooseyard.com> |
Tue Jun 10 16:14:20 2008 -0700 (2008-06-10) | |
changeset 15 | f723174fbc24 |
parent 0 | 9d67172bb323 |
permissions | -rw-r--r-- |
jens@0 | 1 |
// |
jens@0 | 2 |
// TCPWriter.h |
jens@0 | 3 |
// MYNetwork |
jens@0 | 4 |
// |
jens@0 | 5 |
// Created by Jens Alfke on 5/10/08. |
jens@0 | 6 |
// Copyright 2008 Jens Alfke. All rights reserved. |
jens@0 | 7 |
// |
jens@0 | 8 |
|
jens@0 | 9 |
#import "TCPStream.h" |
jens@0 | 10 |
|
jens@0 | 11 |
|
jens@2 | 12 |
/** Output stream for a TCPConnection. Writes a queue of arbitrary data blobs to the socket. */ |
jens@0 | 13 |
@interface TCPWriter : TCPStream |
jens@0 | 14 |
{ |
jens@0 | 15 |
NSMutableArray *_queue; |
jens@0 | 16 |
NSData *_currentData; |
jens@0 | 17 |
SInt32 _currentDataPos; |
jens@0 | 18 |
} |
jens@0 | 19 |
|
jens@0 | 20 |
/** The connection's TCPReader. */ |
jens@0 | 21 |
@property (readonly) TCPReader *reader; |
jens@0 | 22 |
|
jens@0 | 23 |
/** Schedules data to be written to the socket. |
jens@0 | 24 |
Always returns immediately; the bytes won't actually be sent until there's room. */ |
jens@0 | 25 |
- (void) writeData: (NSData*)data; |
jens@0 | 26 |
|
jens@0 | 27 |
//protected: |
jens@0 | 28 |
|
jens@0 | 29 |
/** Will be called when the internal queue of data to be written is empty. |
jens@0 | 30 |
Subclasses should override this and call -writeData: to refill the queue, |
jens@0 | 31 |
if possible. */ |
jens@0 | 32 |
- (void) queueIsEmpty; |
jens@0 | 33 |
|
jens@0 | 34 |
@end |