TCP/TCPWriter.h
author Jens Alfke <jens@mooseyard.com>
Fri Jul 24 14:06:28 2009 -0700 (2009-07-24)
changeset 63 5e4855a592ee
parent 0 9d67172bb323
permissions -rw-r--r--
* The BLIPConnection receivedRequest: delegate method now returns BOOL. If the method returns NO (or if the method isn't implemented in the delegate), that means it didn't handle the message at all; an error will be returned to the sender.
* If the connection closes unexpectedly due to an error, then the auto-generated responses to pending requests will contain that error. This makes it easier to display a meaningful error message in the handler for the request.
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