-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make thrift cocoa lib support TMultiplexedProtocol #150
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// TMultiplexedProtocol.h | ||
// TaLiCaiCommunity | ||
// | ||
// Created by guoyalun on 7/3/14. | ||
// Copyright (c) 2014 guoyalun. All rights reserved. | ||
// | ||
|
||
#import "TProtocolDecorator.h" | ||
|
||
@interface TMultiplexedProtocol : TProtocolDecorator | ||
{ | ||
NSString *_serviceName; | ||
} | ||
|
||
- (id)initWithProtocol:(id <TProtocol>)protocol serviceName:(NSString *)serviceName; | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// TMultiplexedProtocol.m | ||
// TaLiCaiCommunity | ||
// | ||
// Created by guoyalun on 7/3/14. | ||
// Copyright (c) 2014 guoyalun. All rights reserved. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add apache license header and remove other copyright and Created by.as long as you are guoyalun or have his permission |
||
// | ||
|
||
#import "TMultiplexedProtocol.h" | ||
|
||
static NSString *SEPARATOR = @":"; | ||
|
||
@implementation TMultiplexedProtocol | ||
|
||
- (id)initWithProtocol:(id <TProtocol>)protocol serviceName:(NSString *)serviceName | ||
{ | ||
if (self = [super initWithProtocol:protocol]) { | ||
_serviceName = serviceName; | ||
} | ||
return self; | ||
} | ||
|
||
- (void) writeMessageBeginWithName: (NSString *) name | ||
type: (int) messageType | ||
sequenceID: (int) sequenceID | ||
{ | ||
if (messageType == TMessageType_CALL || messageType == TMessageType_ONEWAY) { | ||
|
||
NSString *messageName = [NSString stringWithFormat:@"%@%@%@",_serviceName,SEPARATOR,name]; | ||
[super writeMessageBeginWithName:messageName type:messageType sequenceID:sequenceID]; | ||
} else { | ||
[super writeMessageBeginWithName:name type:messageType sequenceID:sequenceID]; | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// TProtocolDecorator.h | ||
// TaLiCaiCommunity | ||
// | ||
// Created by guoyalun on 7/3/14. | ||
// Copyright (c) 2014 guoyalun. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "TProtocol.h" | ||
|
||
@interface TProtocolDecorator : NSObject <TProtocol> | ||
{ | ||
id<TProtocol> concreteProtocol; | ||
} | ||
- (id)initWithProtocol:(id <TProtocol>)protocol; | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,242 @@ | ||
// | ||
// TProtocolDecorator.m | ||
// TaLiCaiCommunity | ||
// | ||
// Created by guoyalun on 7/3/14. | ||
// Copyright (c) 2014 guoyalun. All rights reserved. | ||
// | ||
|
||
#import "TProtocolDecorator.h" | ||
|
||
@implementation TProtocolDecorator | ||
|
||
- (id)initWithProtocol:(id <TProtocol>)protocol | ||
{ | ||
if (self = [super init]) { | ||
concreteProtocol = protocol; | ||
} | ||
return self; | ||
} | ||
|
||
- (id <TTransport>) transport | ||
{ | ||
return [concreteProtocol transport]; | ||
} | ||
|
||
- (void) readMessageBeginReturningName: (NSString **) name | ||
type: (int *) type | ||
sequenceID: (int *) sequenceID | ||
{ | ||
[concreteProtocol readMessageBeginReturningName:name type:type sequenceID:sequenceID]; | ||
} | ||
- (void) readMessageEnd | ||
{ | ||
[concreteProtocol readMessageEnd]; | ||
} | ||
|
||
- (void) readStructBeginReturningName: (NSString **) name | ||
{ | ||
[concreteProtocol readStructBeginReturningName:name]; | ||
} | ||
- (void) readStructEnd | ||
{ | ||
[concreteProtocol readStructEnd]; | ||
} | ||
|
||
- (void) readFieldBeginReturningName: (NSString **) name | ||
type: (int *) fieldType | ||
fieldID: (int *) fieldID | ||
{ | ||
[concreteProtocol readFieldBeginReturningName:name type:fieldType fieldID:fieldID]; | ||
} | ||
- (void) readFieldEnd | ||
{ | ||
[concreteProtocol readFieldEnd]; | ||
} | ||
|
||
- (NSString *) readString | ||
{ | ||
return [concreteProtocol readString]; | ||
} | ||
|
||
- (BOOL) readBool | ||
{ | ||
return [concreteProtocol readBool]; | ||
} | ||
|
||
- (unsigned char) readByte | ||
{ | ||
return [concreteProtocol readByte]; | ||
} | ||
|
||
- (short) readI16 | ||
{ | ||
return [concreteProtocol readI16]; | ||
} | ||
|
||
- (int32_t) readI32 | ||
{ | ||
return [concreteProtocol readI32]; | ||
} | ||
|
||
- (int64_t) readI64 | ||
{ | ||
return [concreteProtocol readI64]; | ||
} | ||
|
||
- (double) readDouble | ||
{ | ||
return [concreteProtocol readDouble]; | ||
} | ||
|
||
- (NSData *) readBinary | ||
{ | ||
return [concreteProtocol readBinary]; | ||
} | ||
|
||
- (void) readMapBeginReturningKeyType: (int *) keyType | ||
valueType: (int *) valueType | ||
size: (int *) size | ||
{ | ||
return [concreteProtocol readMapBeginReturningKeyType:keyType valueType:valueType size:size]; | ||
} | ||
- (void) readMapEnd | ||
{ | ||
[concreteProtocol readMapEnd]; | ||
} | ||
|
||
|
||
- (void) readSetBeginReturningElementType: (int *) elementType | ||
size: (int *) size | ||
{ | ||
[concreteProtocol readSetBeginReturningElementType:elementType size:size]; | ||
} | ||
- (void) readSetEnd | ||
{ | ||
[concreteProtocol readSetEnd]; | ||
} | ||
|
||
|
||
- (void) readListBeginReturningElementType: (int *) elementType | ||
size: (int *) size | ||
{ | ||
[concreteProtocol readListBeginReturningElementType:elementType size:size]; | ||
} | ||
- (void) readListEnd | ||
{ | ||
[concreteProtocol readListEnd]; | ||
} | ||
|
||
|
||
- (void) writeMessageBeginWithName: (NSString *) name | ||
type: (int) messageType | ||
sequenceID: (int) sequenceID | ||
{ | ||
[concreteProtocol writeMessageBeginWithName:name type:messageType sequenceID:sequenceID]; | ||
} | ||
- (void) writeMessageEnd | ||
{ | ||
[concreteProtocol writeMessageEnd]; | ||
} | ||
|
||
- (void) writeStructBeginWithName: (NSString *) name | ||
{ | ||
[concreteProtocol writeStructBeginWithName:name]; | ||
} | ||
- (void) writeStructEnd | ||
{ | ||
[concreteProtocol writeStructEnd]; | ||
} | ||
|
||
- (void) writeFieldBeginWithName: (NSString *) name | ||
type: (int) fieldType | ||
fieldID: (int) fieldID | ||
{ | ||
[concreteProtocol writeFieldBeginWithName:name type:fieldType fieldID:fieldID]; | ||
} | ||
|
||
- (void) writeI32: (int32_t) value | ||
{ | ||
[concreteProtocol writeI32:value]; | ||
} | ||
|
||
- (void) writeI64: (int64_t) value | ||
{ | ||
[concreteProtocol writeI64:value]; | ||
} | ||
|
||
- (void) writeI16: (short) value | ||
{ | ||
[concreteProtocol writeI16:value]; | ||
} | ||
|
||
- (void) writeByte: (uint8_t) value | ||
{ | ||
[concreteProtocol writeByte:value]; | ||
} | ||
|
||
- (void) writeString: (NSString *) value | ||
{ | ||
[concreteProtocol writeString:value]; | ||
} | ||
|
||
- (void) writeDouble: (double) value | ||
{ | ||
[concreteProtocol writeDouble:value]; | ||
} | ||
|
||
- (void) writeBool: (BOOL) value | ||
{ | ||
[concreteProtocol writeBool:value]; | ||
} | ||
|
||
- (void) writeBinary: (NSData *) data | ||
{ | ||
[concreteProtocol writeBinary:data]; | ||
} | ||
|
||
- (void) writeFieldStop | ||
{ | ||
[concreteProtocol writeFieldStop]; | ||
} | ||
|
||
- (void) writeFieldEnd | ||
{ | ||
[concreteProtocol writeFieldEnd]; | ||
} | ||
|
||
- (void) writeMapBeginWithKeyType: (int) keyType | ||
valueType: (int) valueType | ||
size: (int) size | ||
{ | ||
[concreteProtocol writeMapBeginWithKeyType:keyType valueType:valueType size:size]; | ||
} | ||
- (void) writeMapEnd | ||
{ | ||
[concreteProtocol writeMapEnd]; | ||
} | ||
|
||
|
||
- (void) writeSetBeginWithElementType: (int) elementType | ||
size: (int) size | ||
{ | ||
[concreteProtocol writeSetBeginWithElementType:elementType size:size]; | ||
} | ||
- (void) writeSetEnd | ||
{ | ||
[concreteProtocol writeSetEnd]; | ||
} | ||
|
||
|
||
- (void) writeListBeginWithElementType: (int) elementType | ||
size: (int) size | ||
{ | ||
[concreteProtocol writeListBeginWithElementType:elementType size:size]; | ||
} | ||
|
||
- (void) writeListEnd | ||
{ | ||
[concreteProtocol writeListEnd]; | ||
} | ||
|
||
@end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add apache license header