TCP/TCPEndpoint.m
changeset 12 710113961756
child 26 cb9cdf247239
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/TCP/TCPEndpoint.m	Tue Jun 03 22:24:21 2008 -0700
     1.3 @@ -0,0 +1,84 @@
     1.4 +//
     1.5 +//  BLIPEndpoint.m
     1.6 +//  MYNetwork
     1.7 +//
     1.8 +//  Created by Jens Alfke on 5/14/08.
     1.9 +//  Copyright 2008 Jens Alfke. All rights reserved.
    1.10 +//
    1.11 +
    1.12 +#import "TCPEndpoint.h"
    1.13 +
    1.14 +#import "ExceptionUtils.h"
    1.15 +
    1.16 +
    1.17 +NSString* const kTCPPropertySSLClientSideAuthentication = @"kTCPPropertySSLClientSideAuthentication";
    1.18 +
    1.19 +
    1.20 +@implementation TCPEndpoint
    1.21 +
    1.22 +
    1.23 +- (void) dealloc
    1.24 +{
    1.25 +    [_sslProperties release];
    1.26 +    [super dealloc];
    1.27 +}
    1.28 +
    1.29 +
    1.30 +- (NSMutableDictionary*) SSLProperties {return _sslProperties;}
    1.31 +
    1.32 +- (void) setSSLProperties: (NSMutableDictionary*)props
    1.33 +{
    1.34 +    if( props != _sslProperties ) {
    1.35 +        [_sslProperties release];
    1.36 +        _sslProperties = [props mutableCopy];
    1.37 +    }
    1.38 +}
    1.39 +
    1.40 +- (void) setSSLProperty: (id)value forKey: (NSString*)key
    1.41 +{
    1.42 +    if( value ) {
    1.43 +        if( ! _sslProperties )
    1.44 +            _sslProperties = [[NSMutableDictionary alloc] init];
    1.45 +        [_sslProperties setObject: value forKey: key];
    1.46 +    } else
    1.47 +        [_sslProperties removeObjectForKey: key];
    1.48 +}
    1.49 +
    1.50 +- (NSString*) securityLevel                 {return [_sslProperties objectForKey: (id)kCFStreamSSLLevel];}
    1.51 +- (void) setSecurityLevel: (NSString*)level {[self setSSLProperty: level forKey: (id)kCFStreamSSLLevel];}
    1.52 +
    1.53 +
    1.54 +- (void) tellDelegate: (SEL)selector withObject: (id)param
    1.55 +{
    1.56 +    if( [_delegate respondsToSelector: selector] ) {
    1.57 +        @try{
    1.58 +            [_delegate performSelector: selector withObject: self withObject: param];
    1.59 +        }catchAndReport(@"%@ delegate",self.class);
    1.60 +    }
    1.61 +}
    1.62 +
    1.63 +
    1.64 +@end
    1.65 +
    1.66 +
    1.67 +/*
    1.68 + Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
    1.69 + 
    1.70 + Redistribution and use in source and binary forms, with or without modification, are permitted
    1.71 + provided that the following conditions are met:
    1.72 + 
    1.73 + * Redistributions of source code must retain the above copyright notice, this list of conditions
    1.74 + and the following disclaimer.
    1.75 + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
    1.76 + and the following disclaimer in the documentation and/or other materials provided with the
    1.77 + distribution.
    1.78 + 
    1.79 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
    1.80 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
    1.81 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
    1.82 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    1.83 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
    1.84 +  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
    1.85 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
    1.86 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.87 + */