TCP/TCPEndpoint.m
author snej@snej.local
Tue Dec 02 22:42:56 2008 -0800 (2008-12-02)
changeset 25 a4875607a3a0
child 26 cb9cdf247239
permissions -rw-r--r--
Added iPhone demo project
jens@0
     1
//
jens@0
     2
//  BLIPEndpoint.m
jens@0
     3
//  MYNetwork
jens@0
     4
//
jens@0
     5
//  Created by Jens Alfke on 5/14/08.
jens@0
     6
//  Copyright 2008 Jens Alfke. All rights reserved.
jens@0
     7
//
jens@0
     8
jens@0
     9
#import "TCPEndpoint.h"
jens@0
    10
jens@0
    11
#import "ExceptionUtils.h"
jens@0
    12
jens@0
    13
jens@0
    14
NSString* const kTCPPropertySSLClientSideAuthentication = @"kTCPPropertySSLClientSideAuthentication";
jens@0
    15
jens@0
    16
jens@0
    17
@implementation TCPEndpoint
jens@0
    18
jens@0
    19
jens@0
    20
- (void) dealloc
jens@0
    21
{
jens@0
    22
    [_sslProperties release];
jens@0
    23
    [super dealloc];
jens@0
    24
}
jens@0
    25
jens@0
    26
jens@0
    27
- (NSMutableDictionary*) SSLProperties {return _sslProperties;}
jens@0
    28
jens@0
    29
- (void) setSSLProperties: (NSMutableDictionary*)props
jens@0
    30
{
jens@0
    31
    if( props != _sslProperties ) {
jens@0
    32
        [_sslProperties release];
jens@0
    33
        _sslProperties = [props mutableCopy];
jens@0
    34
    }
jens@0
    35
}
jens@0
    36
jens@0
    37
- (void) setSSLProperty: (id)value forKey: (NSString*)key
jens@0
    38
{
jens@0
    39
    if( value ) {
jens@0
    40
        if( ! _sslProperties )
jens@0
    41
            _sslProperties = [[NSMutableDictionary alloc] init];
jens@0
    42
        [_sslProperties setObject: value forKey: key];
jens@0
    43
    } else
jens@0
    44
        [_sslProperties removeObjectForKey: key];
jens@0
    45
}
jens@0
    46
jens@0
    47
- (NSString*) securityLevel                 {return [_sslProperties objectForKey: (id)kCFStreamSSLLevel];}
jens@0
    48
- (void) setSecurityLevel: (NSString*)level {[self setSSLProperty: level forKey: (id)kCFStreamSSLLevel];}
jens@0
    49
jens@0
    50
jens@0
    51
- (void) tellDelegate: (SEL)selector withObject: (id)param
jens@0
    52
{
jens@0
    53
    if( [_delegate respondsToSelector: selector] ) {
jens@0
    54
        @try{
jens@0
    55
            [_delegate performSelector: selector withObject: self withObject: param];
jens@0
    56
        }catchAndReport(@"%@ delegate",self.class);
jens@0
    57
    }
jens@0
    58
}
jens@0
    59
jens@0
    60
jens@0
    61
@end
jens@0
    62
jens@0
    63
jens@0
    64
/*
jens@0
    65
 Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
jens@0
    66
 
jens@0
    67
 Redistribution and use in source and binary forms, with or without modification, are permitted
jens@0
    68
 provided that the following conditions are met:
jens@0
    69
 
jens@0
    70
 * Redistributions of source code must retain the above copyright notice, this list of conditions
jens@0
    71
 and the following disclaimer.
jens@0
    72
 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
jens@0
    73
 and the following disclaimer in the documentation and/or other materials provided with the
jens@0
    74
 distribution.
jens@0
    75
 
jens@0
    76
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
jens@0
    77
 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
jens@0
    78
 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
jens@0
    79
 BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
jens@0
    80
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
jens@0
    81
  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
jens@0
    82
 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
jens@0
    83
 THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
jens@0
    84
 */