BLIP/BLIPConnection.m
changeset 63 5e4855a592ee
parent 49 20cccc7c26ee
     1.1 --- a/BLIP/BLIPConnection.m	Sun May 24 15:03:39 2009 -0700
     1.2 +++ b/BLIP/BLIPConnection.m	Fri Jul 24 14:06:28 2009 -0700
     1.3 @@ -69,13 +69,14 @@
     1.4  }
     1.5  
     1.6  
     1.7 -- (void) _dispatchMetaRequest: (BLIPRequest*)request
     1.8 +- (BOOL) _dispatchMetaRequest: (BLIPRequest*)request
     1.9  {
    1.10      NSString* profile = request.profile;
    1.11 -    if( [profile isEqualToString: kBLIPProfile_Bye] )
    1.12 +    if( [profile isEqualToString: kBLIPProfile_Bye] ) {
    1.13          [self _handleCloseRequest: request];
    1.14 -    else
    1.15 -        [request respondWithErrorCode: kBLIPError_NotFound message: @"Unknown meta profile"];
    1.16 +        return YES;
    1.17 +    }
    1.18 +    return NO;
    1.19  }
    1.20  
    1.21  
    1.22 @@ -83,11 +84,19 @@
    1.23  {
    1.24      LogTo(BLIP,@"Received all of %@",request.descriptionWithProperties);
    1.25      @try{
    1.26 +        BOOL handled;
    1.27          if( request._flags & kBLIP_Meta )
    1.28 -            [self _dispatchMetaRequest: request];
    1.29 -        else if( ! [self.dispatcher dispatchMessage: request] )
    1.30 -            [self tellDelegate: @selector(connection:receivedRequest:) withObject: request];
    1.31 -        if( ! request.noReply && ! request.repliedTo ) {
    1.32 +            handled =[self _dispatchMetaRequest: request];
    1.33 +        else {
    1.34 +            handled = [self.dispatcher dispatchMessage: request];
    1.35 +            if (!handled && [_delegate respondsToSelector: @selector(connection:receivedRequest:)])
    1.36 +                handled = [_delegate connection: self receivedRequest: request];
    1.37 +        }
    1.38 +        
    1.39 +        if (!handled) {
    1.40 +            LogTo(BLIP,@"No handler found for incoming %@",request);
    1.41 +            [request respondWithErrorCode: kBLIPError_NotFound message: @"No handler was found"];
    1.42 +        } else if( ! request.noReply && ! request.repliedTo ) {
    1.43              LogTo(BLIP,@"Returning default empty response to %@",request);
    1.44              [request respondWithData: nil contentType: nil];
    1.45          }