| Jens Geyer | aa99e0e | 2014-09-29 22:09:15 +0200 | [diff] [blame] | 1 | /* | 
 | 2 |  * Licensed to the Apache Software Foundation (ASF) under one | 
 | 3 |  * or more contributor license agreements. See the NOTICE file | 
 | 4 |  * distributed with this work for additional information | 
 | 5 |  * regarding copyright ownership. The ASF licenses this file | 
 | 6 |  * to you under the Apache License, Version 2.0 (the | 
 | 7 |  * "License"); you may not use this file except in compliance | 
 | 8 |  * with the License. You may obtain a copy of the License at | 
 | 9 |  * | 
 | 10 |  *   http://www.apache.org/licenses/LICENSE-2.0 | 
 | 11 |  * | 
 | 12 |  * Unless required by applicable law or agreed to in writing, | 
 | 13 |  * software distributed under the License is distributed on an | 
 | 14 |  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | 
 | 15 |  * KIND, either express or implied. See the License for the | 
 | 16 |  * specific language governing permissions and limitations | 
 | 17 |  * under the License. | 
 | 18 |  */ | 
 | 19 |  | 
 | 20 | #import "TMultiplexedProtocol.h" | 
 | 21 |  | 
 | 22 | #import "TProtocol.h" | 
 | 23 | #import "TObjective-C.h" | 
 | 24 |  | 
 | 25 | NSString *const MULTIPLEXED_SERVICE_SEPERATOR = @":"; | 
 | 26 |  | 
 | 27 | @implementation TMultiplexedProtocol | 
 | 28 |  | 
 | 29 | - (id) initWithProtocol: (id <TProtocol>) protocol | 
 | 30 |             serviceName: (NSString *) name | 
 | 31 | { | 
 | 32 |     self = [super initWithProtocol:protocol]; | 
 | 33 |  | 
 | 34 |     if (self) { | 
 | 35 |         mServiceName = [name retain_stub]; | 
 | 36 |     } | 
 | 37 |     return self; | 
 | 38 | } | 
 | 39 |  | 
 | 40 | - (void) writeMessageBeginWithName: (NSString *) name | 
 | 41 |                               type: (int) messageType | 
 | 42 |                         sequenceID: (int) sequenceID | 
 | 43 | { | 
 | 44 |     switch (messageType) { | 
 | 45 |         case TMessageType_CALL: | 
 | 46 |         case TMessageType_ONEWAY: | 
 | 47 |             { | 
 | 48 |                 NSMutableString * serviceFunction = [[NSMutableString alloc] initWithString:mServiceName]; | 
 | 49 |                 [serviceFunction appendString:MULTIPLEXED_SERVICE_SEPERATOR]; | 
 | 50 |                 [serviceFunction appendString:name]; | 
 | 51 |                 [super writeMessageBeginWithName:serviceFunction type:messageType sequenceID:sequenceID]; | 
 | 52 |                 [serviceFunction release_stub]; | 
 | 53 |             } | 
 | 54 |             break; | 
 | 55 |         default: | 
 | 56 |             [super writeMessageBeginWithName:name type:messageType sequenceID:sequenceID]; | 
 | 57 |             break; | 
 | 58 |     } | 
 | 59 | } | 
 | 60 |  | 
 | 61 | - (void) dealloc | 
 | 62 | { | 
 | 63 |     [mServiceName release_stub]; | 
 | 64 |     [super dealloc_stub]; | 
 | 65 | } | 
 | 66 |  | 
 | 67 | @end |