From 67110d0def3ffc38dfd653a16987ae289fd5ecb4 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 6 Aug 2018 10:21:16 -0400 Subject: [PATCH] Migrate to websocket proto wrappers. --- Signal/SignalUBSan.supp | 1 - .../protobuf/WebSocketResources.proto | 1 - .../src/Network/WebSockets/TSSocketManager.m | 92 +- .../WebSockets/WebSocketResources.pb.h | 330 ----- .../WebSockets/WebSocketResources.pb.m | 1233 ----------------- .../src/Protos/Generated/WebSocketProto.swift | 24 +- .../Generated/WebSocketResources.pb.swift | 41 +- 7 files changed, 83 insertions(+), 1639 deletions(-) delete mode 100644 SignalServiceKit/src/Network/WebSockets/WebSocketResources.pb.h delete mode 100644 SignalServiceKit/src/Network/WebSockets/WebSocketResources.pb.m diff --git a/Signal/SignalUBSan.supp b/Signal/SignalUBSan.supp index 407b98156..dd9c27f84 100644 --- a/Signal/SignalUBSan.supp +++ b/Signal/SignalUBSan.supp @@ -4,7 +4,6 @@ # protobuf lib shift-base:CodedInputStream.m # generated protos -bool:WebSocketResources.pb.m bool:WhisperTextProtocol.pb.m bool:OWSWebRTCDataProtos.pb.m diff --git a/SignalServiceKit/protobuf/WebSocketResources.proto b/SignalServiceKit/protobuf/WebSocketResources.proto index bb354a746..709e200d7 100644 --- a/SignalServiceKit/protobuf/WebSocketResources.proto +++ b/SignalServiceKit/protobuf/WebSocketResources.proto @@ -32,7 +32,6 @@ message WebSocketResponseMessage { optional uint32 status = 2; optional string message = 3; repeated string headers = 5; - // @required optional bytes body = 4; } diff --git a/SignalServiceKit/src/Network/WebSockets/TSSocketManager.m b/SignalServiceKit/src/Network/WebSockets/TSSocketManager.m index 2f27cccc6..084c58e8b 100644 --- a/SignalServiceKit/src/Network/WebSockets/TSSocketManager.m +++ b/SignalServiceKit/src/Network/WebSockets/TSSocketManager.m @@ -22,7 +22,6 @@ #import "TSRequest.h" #import "TextSecureKitEnv.h" #import "Threading.h" -#import "WebSocketResources.pb.h" #import NS_ASSUME_NONNULL_BEGIN @@ -492,26 +491,32 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_ } } - WebSocketResourcesWebSocketRequestMessageBuilder *requestBuilder = - [WebSocketResourcesWebSocketRequestMessageBuilder new]; - [requestBuilder setRequestId:socketMessage.requestId]; + WebSocketProtoWebSocketRequestMessageBuilder *requestBuilder = [WebSocketProtoWebSocketRequestMessageBuilder new]; + [requestBuilder setRequestID:socketMessage.requestId]; [requestBuilder setVerb:request.HTTPMethod]; [requestBuilder setPath:requestPath]; if (jsonData) { // TODO: Do we need body & headers for requests with no parameters? [requestBuilder setBody:jsonData]; - [requestBuilder setHeadersArray:@[ + [requestBuilder setHeaders:@[ @"content-type:application/json", ]]; } - WebSocketResourcesWebSocketMessageBuilder *messageBuilder = [WebSocketResourcesWebSocketMessageBuilder new]; - [messageBuilder setType:WebSocketResourcesWebSocketMessageTypeRequest]; - [messageBuilder setRequestBuilder:requestBuilder]; + NSError *error; + WebSocketProtoWebSocketRequestMessage *_Nullable requestProto = [requestBuilder buildAndReturnError:&error]; + if (!requestProto || error) { + OWSFail(@"%@ could not build proto: %@", self.logTag, error); + return; + } - NSData *messageData = [messageBuilder build].data; - if (!messageData) { - OWSProdLogAndFail(@"%@ could not serialize message.", self.logTag); + WebSocketProtoWebSocketMessageBuilder *messageBuilder = [WebSocketProtoWebSocketMessageBuilder new]; + [messageBuilder setType:WebSocketProtoWebSocketMessageTypeRequest]; + [messageBuilder setRequest:requestProto]; + + NSData *_Nullable messageData = [messageBuilder buildSerializedDataAndReturnError:&error]; + if (!messageData || error) { + OWSProdLogAndFail(@"%@ could not serialize proto: %@.", self.logTag, error); [socketMessage didFailBeforeSending]; return; } @@ -522,7 +527,6 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_ return; } - NSError *error; BOOL wasScheduled = [self.websocket sendDataNoCopy:messageData error:&error]; if (!wasScheduled || error) { OWSProdLogAndFail(@"%@ could not send socket request: %@", self.logTag, error); @@ -545,7 +549,7 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_ }); } -- (void)processWebSocketResponseMessage:(WebSocketResourcesWebSocketResponseMessage *)message +- (void)processWebSocketResponseMessage:(WebSocketProtoWebSocketResponseMessage *)message { OWSAssertIsOnMainThread(); OWSAssert(message); @@ -555,26 +559,18 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_ }); } -- (void)processWebSocketResponseMessageAsync:(WebSocketResourcesWebSocketResponseMessage *)message +- (void)processWebSocketResponseMessageAsync:(WebSocketProtoWebSocketResponseMessage *)message { OWSAssert(message); DDLogInfo(@"%@ received WebSocket response.", self.logTag); - if (![message hasRequestId]) { - DDLogError(@"%@ received incomplete WebSocket response.", self.logTag); - return; - } - DispatchMainThreadSafe(^{ [self requestSocketAliveForAtLeastSeconds:kMakeRequestKeepSocketAliveDurationSeconds]; }); - UInt64 requestId = message.requestId; - UInt32 responseStatus = 0; - if (message.hasStatus) { - responseStatus = message.status; - } + UInt64 requestId = message.requestID; + UInt32 responseStatus = message.status; NSString *_Nullable responseMessage; if (message.hasMessage) { responseMessage = message.message; @@ -702,25 +698,30 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_ // If we receive a response, we know we're not de-registered. [TSAccountManager.sharedInstance setIsDeregistered:NO]; - WebSocketResourcesWebSocketMessage *wsMessage; + WebSocketProtoWebSocketMessage *_Nullable wsMessage; @try { - wsMessage = [WebSocketResourcesWebSocketMessage parseFromData:data]; + NSError *error; + wsMessage = [WebSocketProtoWebSocketMessage parseData:data error:&error]; + if (!wsMessage || error) { + OWSFail(@"%@ could not parse proto: %@", self.logTag, error); + return; + } } @catch (NSException *exception) { OWSProdLogAndFail(@"%@ Received an invalid message: %@", self.logTag, exception.debugDescription); // TODO: Add analytics. return; } - if (wsMessage.type == WebSocketResourcesWebSocketMessageTypeRequest) { + if (wsMessage.type == WebSocketProtoWebSocketMessageTypeRequest) { [self processWebSocketRequestMessage:wsMessage.request]; - } else if (wsMessage.type == WebSocketResourcesWebSocketMessageTypeResponse) { + } else if (wsMessage.type == WebSocketProtoWebSocketMessageTypeResponse) { [self processWebSocketResponseMessage:wsMessage.response]; } else { DDLogWarn(@"%@ webSocket:didReceiveMessage: unknown.", self.logTag); } } -- (void)processWebSocketRequestMessage:(WebSocketResourcesWebSocketRequestMessage *)message +- (void)processWebSocketRequestMessage:(WebSocketProtoWebSocketRequestMessage *)message { OWSAssertIsOnMainThread(); @@ -779,21 +780,34 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_ } } -- (void)sendWebSocketMessageAcknowledgement:(WebSocketResourcesWebSocketRequestMessage *)request +- (void)sendWebSocketMessageAcknowledgement:(WebSocketProtoWebSocketRequestMessage *)request { OWSAssertIsOnMainThread(); - WebSocketResourcesWebSocketResponseMessageBuilder *response = [WebSocketResourcesWebSocketResponseMessage builder]; - [response setStatus:200]; - [response setMessage:@"OK"]; - [response setRequestId:request.requestId]; + NSError *error; + + WebSocketProtoWebSocketResponseMessageBuilder *responseBuilder = + [WebSocketProtoWebSocketResponseMessageBuilder new]; + [responseBuilder setStatus:200]; + [responseBuilder setMessage:@"OK"]; + [responseBuilder setRequestID:request.requestID]; + WebSocketProtoWebSocketResponseMessage *_Nullable response = [responseBuilder buildAndReturnError:&error]; + if (!response || error) { + OWSFail(@"%@ could not build proto: %@", self.logTag, error); + return; + } + + WebSocketProtoWebSocketMessageBuilder *messageBuilder = [WebSocketProtoWebSocketMessageBuilder new]; + [messageBuilder setResponse:response]; + [messageBuilder setType:WebSocketProtoWebSocketMessageTypeResponse]; - WebSocketResourcesWebSocketMessageBuilder *message = [WebSocketResourcesWebSocketMessage builder]; - [message setResponse:response.build]; - [message setType:WebSocketResourcesWebSocketMessageTypeResponse]; + NSData *_Nullable messageData = [messageBuilder buildSerializedDataAndReturnError:&error]; + if (!messageData || error) { + OWSFail(@"%@ could not serialize proto: %@", self.logTag, error); + return; + } - NSError *error; - [self.websocket sendDataNoCopy:message.build.data error:&error]; + [self.websocket sendDataNoCopy:messageData error:&error]; if (error) { DDLogWarn(@"Error while trying to write on websocket %@", error); [self handleSocketFailure]; diff --git a/SignalServiceKit/src/Network/WebSockets/WebSocketResources.pb.h b/SignalServiceKit/src/Network/WebSockets/WebSocketResources.pb.h deleted file mode 100644 index dec3ca504..000000000 --- a/SignalServiceKit/src/Network/WebSockets/WebSocketResources.pb.h +++ /dev/null @@ -1,330 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! - -#import - -// @@protoc_insertion_point(imports) - -@class ObjectiveCFileOptions; -@class ObjectiveCFileOptionsBuilder; -@class PBDescriptorProto; -@class PBDescriptorProtoBuilder; -@class PBDescriptorProtoExtensionRange; -@class PBDescriptorProtoExtensionRangeBuilder; -@class PBEnumDescriptorProto; -@class PBEnumDescriptorProtoBuilder; -@class PBEnumOptions; -@class PBEnumOptionsBuilder; -@class PBEnumValueDescriptorProto; -@class PBEnumValueDescriptorProtoBuilder; -@class PBEnumValueOptions; -@class PBEnumValueOptionsBuilder; -@class PBFieldDescriptorProto; -@class PBFieldDescriptorProtoBuilder; -@class PBFieldOptions; -@class PBFieldOptionsBuilder; -@class PBFileDescriptorProto; -@class PBFileDescriptorProtoBuilder; -@class PBFileDescriptorSet; -@class PBFileDescriptorSetBuilder; -@class PBFileOptions; -@class PBFileOptionsBuilder; -@class PBMessageOptions; -@class PBMessageOptionsBuilder; -@class PBMethodDescriptorProto; -@class PBMethodDescriptorProtoBuilder; -@class PBMethodOptions; -@class PBMethodOptionsBuilder; -@class PBOneofDescriptorProto; -@class PBOneofDescriptorProtoBuilder; -@class PBServiceDescriptorProto; -@class PBServiceDescriptorProtoBuilder; -@class PBServiceOptions; -@class PBServiceOptionsBuilder; -@class PBSourceCodeInfo; -@class PBSourceCodeInfoBuilder; -@class PBSourceCodeInfoLocation; -@class PBSourceCodeInfoLocationBuilder; -@class PBUninterpretedOption; -@class PBUninterpretedOptionBuilder; -@class PBUninterpretedOptionNamePart; -@class PBUninterpretedOptionNamePartBuilder; -@class WebSocketResourcesWebSocketMessage; -@class WebSocketResourcesWebSocketMessageBuilder; -@class WebSocketResourcesWebSocketRequestMessage; -@class WebSocketResourcesWebSocketRequestMessageBuilder; -@class WebSocketResourcesWebSocketResponseMessage; -@class WebSocketResourcesWebSocketResponseMessageBuilder; - - -typedef NS_ENUM(SInt32, WebSocketResourcesWebSocketMessageType) { - WebSocketResourcesWebSocketMessageTypeUnknown = 0, - WebSocketResourcesWebSocketMessageTypeRequest = 1, - WebSocketResourcesWebSocketMessageTypeResponse = 2, -}; - -BOOL WebSocketResourcesWebSocketMessageTypeIsValidValue(WebSocketResourcesWebSocketMessageType value); -NSString *NSStringFromWebSocketResourcesWebSocketMessageType(WebSocketResourcesWebSocketMessageType value); - - -@interface WebSocketResourcesWebSocketResourcesRoot : NSObject { -} -+ (PBExtensionRegistry*) extensionRegistry; -+ (void) registerAllExtensions:(PBMutableExtensionRegistry*) registry; -@end - -#define WebSocketRequestMessage_verb @"verb" -#define WebSocketRequestMessage_path @"path" -#define WebSocketRequestMessage_body @"body" -#define WebSocketRequestMessage_headers @"headers" -#define WebSocketRequestMessage_requestId @"requestId" -@interface WebSocketResourcesWebSocketRequestMessage : PBGeneratedMessage { -@private - BOOL hasRequestId_:1; - BOOL hasVerb_:1; - BOOL hasPath_:1; - BOOL hasBody_:1; - UInt64 requestId; - NSString* verb; - NSString* path; - NSData* body; - NSMutableArray * headersArray; -} -- (BOOL) hasVerb; -- (BOOL) hasPath; -- (BOOL) hasBody; -- (BOOL) hasRequestId; -@property (readonly, strong) NSString* verb; -@property (readonly, strong) NSString* path; -@property (readonly, strong) NSData* body; -@property (readonly, strong) NSArray * headers; -@property (readonly) UInt64 requestId; -- (NSString*)headersAtIndex:(NSUInteger)index; - -+ (instancetype) defaultInstance; -- (instancetype) defaultInstance; - -- (BOOL) isInitialized; -- (void) writeToCodedOutputStream:(PBCodedOutputStream*) output; -- (WebSocketResourcesWebSocketRequestMessageBuilder*) builder; -+ (WebSocketResourcesWebSocketRequestMessageBuilder*) builder; -+ (WebSocketResourcesWebSocketRequestMessageBuilder*) builderWithPrototype:(WebSocketResourcesWebSocketRequestMessage*) prototype; -- (WebSocketResourcesWebSocketRequestMessageBuilder*) toBuilder; - -+ (WebSocketResourcesWebSocketRequestMessage*) parseFromData:(NSData*) data; -+ (WebSocketResourcesWebSocketRequestMessage*) parseFromData:(NSData*) data extensionRegistry:(PBExtensionRegistry*) extensionRegistry; -+ (WebSocketResourcesWebSocketRequestMessage*) parseFromInputStream:(NSInputStream*) input; -+ (WebSocketResourcesWebSocketRequestMessage*) parseFromInputStream:(NSInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry; -+ (WebSocketResourcesWebSocketRequestMessage*) parseFromCodedInputStream:(PBCodedInputStream*) input; -+ (WebSocketResourcesWebSocketRequestMessage*) parseFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry; -@end - -@interface WebSocketResourcesWebSocketRequestMessageBuilder : PBGeneratedMessageBuilder { -@private - WebSocketResourcesWebSocketRequestMessage* resultWebSocketRequestMessage; -} - -- (WebSocketResourcesWebSocketRequestMessage*) defaultInstance; - -- (WebSocketResourcesWebSocketRequestMessageBuilder*) clear; -- (WebSocketResourcesWebSocketRequestMessageBuilder*) clone; - -- (WebSocketResourcesWebSocketRequestMessage*) build; -- (WebSocketResourcesWebSocketRequestMessage*) buildPartial; - -- (WebSocketResourcesWebSocketRequestMessageBuilder*) mergeFrom:(WebSocketResourcesWebSocketRequestMessage*) other; -- (WebSocketResourcesWebSocketRequestMessageBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input; -- (WebSocketResourcesWebSocketRequestMessageBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry; - -- (BOOL) hasVerb; -- (NSString*) verb; -- (WebSocketResourcesWebSocketRequestMessageBuilder*) setVerb:(NSString*) value; -- (WebSocketResourcesWebSocketRequestMessageBuilder*) clearVerb; - -- (BOOL) hasPath; -- (NSString*) path; -- (WebSocketResourcesWebSocketRequestMessageBuilder*) setPath:(NSString*) value; -- (WebSocketResourcesWebSocketRequestMessageBuilder*) clearPath; - -- (BOOL) hasBody; -- (NSData*) body; -- (WebSocketResourcesWebSocketRequestMessageBuilder*) setBody:(NSData*) value; -- (WebSocketResourcesWebSocketRequestMessageBuilder*) clearBody; - -- (NSMutableArray *)headers; -- (NSString*)headersAtIndex:(NSUInteger)index; -- (WebSocketResourcesWebSocketRequestMessageBuilder *)addHeaders:(NSString*)value; -- (WebSocketResourcesWebSocketRequestMessageBuilder *)setHeadersArray:(NSArray *)array; -- (WebSocketResourcesWebSocketRequestMessageBuilder *)clearHeaders; - -- (BOOL) hasRequestId; -- (UInt64) requestId; -- (WebSocketResourcesWebSocketRequestMessageBuilder*) setRequestId:(UInt64) value; -- (WebSocketResourcesWebSocketRequestMessageBuilder*) clearRequestId; -@end - -#define WebSocketResponseMessage_requestId @"requestId" -#define WebSocketResponseMessage_status @"status" -#define WebSocketResponseMessage_message @"message" -#define WebSocketResponseMessage_headers @"headers" -#define WebSocketResponseMessage_body @"body" -@interface WebSocketResourcesWebSocketResponseMessage : PBGeneratedMessage { -@private - BOOL hasRequestId_:1; - BOOL hasMessage_:1; - BOOL hasBody_:1; - BOOL hasStatus_:1; - UInt64 requestId; - NSString* message; - NSData* body; - UInt32 status; - NSMutableArray * headersArray; -} -- (BOOL) hasRequestId; -- (BOOL) hasStatus; -- (BOOL) hasMessage; -- (BOOL) hasBody; -@property (readonly) UInt64 requestId; -@property (readonly) UInt32 status; -@property (readonly, strong) NSString* message; -@property (readonly, strong) NSArray * headers; -@property (readonly, strong) NSData* body; -- (NSString*)headersAtIndex:(NSUInteger)index; - -+ (instancetype) defaultInstance; -- (instancetype) defaultInstance; - -- (BOOL) isInitialized; -- (void) writeToCodedOutputStream:(PBCodedOutputStream*) output; -- (WebSocketResourcesWebSocketResponseMessageBuilder*) builder; -+ (WebSocketResourcesWebSocketResponseMessageBuilder*) builder; -+ (WebSocketResourcesWebSocketResponseMessageBuilder*) builderWithPrototype:(WebSocketResourcesWebSocketResponseMessage*) prototype; -- (WebSocketResourcesWebSocketResponseMessageBuilder*) toBuilder; - -+ (WebSocketResourcesWebSocketResponseMessage*) parseFromData:(NSData*) data; -+ (WebSocketResourcesWebSocketResponseMessage*) parseFromData:(NSData*) data extensionRegistry:(PBExtensionRegistry*) extensionRegistry; -+ (WebSocketResourcesWebSocketResponseMessage*) parseFromInputStream:(NSInputStream*) input; -+ (WebSocketResourcesWebSocketResponseMessage*) parseFromInputStream:(NSInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry; -+ (WebSocketResourcesWebSocketResponseMessage*) parseFromCodedInputStream:(PBCodedInputStream*) input; -+ (WebSocketResourcesWebSocketResponseMessage*) parseFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry; -@end - -@interface WebSocketResourcesWebSocketResponseMessageBuilder : PBGeneratedMessageBuilder { -@private - WebSocketResourcesWebSocketResponseMessage* resultWebSocketResponseMessage; -} - -- (WebSocketResourcesWebSocketResponseMessage*) defaultInstance; - -- (WebSocketResourcesWebSocketResponseMessageBuilder*) clear; -- (WebSocketResourcesWebSocketResponseMessageBuilder*) clone; - -- (WebSocketResourcesWebSocketResponseMessage*) build; -- (WebSocketResourcesWebSocketResponseMessage*) buildPartial; - -- (WebSocketResourcesWebSocketResponseMessageBuilder*) mergeFrom:(WebSocketResourcesWebSocketResponseMessage*) other; -- (WebSocketResourcesWebSocketResponseMessageBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input; -- (WebSocketResourcesWebSocketResponseMessageBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry; - -- (BOOL) hasRequestId; -- (UInt64) requestId; -- (WebSocketResourcesWebSocketResponseMessageBuilder*) setRequestId:(UInt64) value; -- (WebSocketResourcesWebSocketResponseMessageBuilder*) clearRequestId; - -- (BOOL) hasStatus; -- (UInt32) status; -- (WebSocketResourcesWebSocketResponseMessageBuilder*) setStatus:(UInt32) value; -- (WebSocketResourcesWebSocketResponseMessageBuilder*) clearStatus; - -- (BOOL) hasMessage; -- (NSString*) message; -- (WebSocketResourcesWebSocketResponseMessageBuilder*) setMessage:(NSString*) value; -- (WebSocketResourcesWebSocketResponseMessageBuilder*) clearMessage; - -- (NSMutableArray *)headers; -- (NSString*)headersAtIndex:(NSUInteger)index; -- (WebSocketResourcesWebSocketResponseMessageBuilder *)addHeaders:(NSString*)value; -- (WebSocketResourcesWebSocketResponseMessageBuilder *)setHeadersArray:(NSArray *)array; -- (WebSocketResourcesWebSocketResponseMessageBuilder *)clearHeaders; - -- (BOOL) hasBody; -- (NSData*) body; -- (WebSocketResourcesWebSocketResponseMessageBuilder*) setBody:(NSData*) value; -- (WebSocketResourcesWebSocketResponseMessageBuilder*) clearBody; -@end - -#define WebSocketMessage_type @"type" -#define WebSocketMessage_request @"request" -#define WebSocketMessage_response @"response" -@interface WebSocketResourcesWebSocketMessage : PBGeneratedMessage { -@private - BOOL hasRequest_:1; - BOOL hasResponse_:1; - BOOL hasType_:1; - WebSocketResourcesWebSocketRequestMessage* request; - WebSocketResourcesWebSocketResponseMessage* response; - WebSocketResourcesWebSocketMessageType type; -} -- (BOOL) hasType; -- (BOOL) hasRequest; -- (BOOL) hasResponse; -@property (readonly) WebSocketResourcesWebSocketMessageType type; -@property (readonly, strong) WebSocketResourcesWebSocketRequestMessage* request; -@property (readonly, strong) WebSocketResourcesWebSocketResponseMessage* response; - -+ (instancetype) defaultInstance; -- (instancetype) defaultInstance; - -- (BOOL) isInitialized; -- (void) writeToCodedOutputStream:(PBCodedOutputStream*) output; -- (WebSocketResourcesWebSocketMessageBuilder*) builder; -+ (WebSocketResourcesWebSocketMessageBuilder*) builder; -+ (WebSocketResourcesWebSocketMessageBuilder*) builderWithPrototype:(WebSocketResourcesWebSocketMessage*) prototype; -- (WebSocketResourcesWebSocketMessageBuilder*) toBuilder; - -+ (WebSocketResourcesWebSocketMessage*) parseFromData:(NSData*) data; -+ (WebSocketResourcesWebSocketMessage*) parseFromData:(NSData*) data extensionRegistry:(PBExtensionRegistry*) extensionRegistry; -+ (WebSocketResourcesWebSocketMessage*) parseFromInputStream:(NSInputStream*) input; -+ (WebSocketResourcesWebSocketMessage*) parseFromInputStream:(NSInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry; -+ (WebSocketResourcesWebSocketMessage*) parseFromCodedInputStream:(PBCodedInputStream*) input; -+ (WebSocketResourcesWebSocketMessage*) parseFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry; -@end - -@interface WebSocketResourcesWebSocketMessageBuilder : PBGeneratedMessageBuilder { -@private - WebSocketResourcesWebSocketMessage* resultWebSocketMessage; -} - -- (WebSocketResourcesWebSocketMessage*) defaultInstance; - -- (WebSocketResourcesWebSocketMessageBuilder*) clear; -- (WebSocketResourcesWebSocketMessageBuilder*) clone; - -- (WebSocketResourcesWebSocketMessage*) build; -- (WebSocketResourcesWebSocketMessage*) buildPartial; - -- (WebSocketResourcesWebSocketMessageBuilder*) mergeFrom:(WebSocketResourcesWebSocketMessage*) other; -- (WebSocketResourcesWebSocketMessageBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input; -- (WebSocketResourcesWebSocketMessageBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry; - -- (BOOL) hasType; -- (WebSocketResourcesWebSocketMessageType) type; -- (WebSocketResourcesWebSocketMessageBuilder*) setType:(WebSocketResourcesWebSocketMessageType) value; -- (WebSocketResourcesWebSocketMessageBuilder*) clearType; - -- (BOOL) hasRequest; -- (WebSocketResourcesWebSocketRequestMessage*) request; -- (WebSocketResourcesWebSocketMessageBuilder*) setRequest:(WebSocketResourcesWebSocketRequestMessage*) value; -- (WebSocketResourcesWebSocketMessageBuilder*) setRequestBuilder:(WebSocketResourcesWebSocketRequestMessageBuilder*) builderForValue; -- (WebSocketResourcesWebSocketMessageBuilder*) mergeRequest:(WebSocketResourcesWebSocketRequestMessage*) value; -- (WebSocketResourcesWebSocketMessageBuilder*) clearRequest; - -- (BOOL) hasResponse; -- (WebSocketResourcesWebSocketResponseMessage*) response; -- (WebSocketResourcesWebSocketMessageBuilder*) setResponse:(WebSocketResourcesWebSocketResponseMessage*) value; -- (WebSocketResourcesWebSocketMessageBuilder*) setResponseBuilder:(WebSocketResourcesWebSocketResponseMessageBuilder*) builderForValue; -- (WebSocketResourcesWebSocketMessageBuilder*) mergeResponse:(WebSocketResourcesWebSocketResponseMessage*) value; -- (WebSocketResourcesWebSocketMessageBuilder*) clearResponse; -@end - - -// @@protoc_insertion_point(global_scope) diff --git a/SignalServiceKit/src/Network/WebSockets/WebSocketResources.pb.m b/SignalServiceKit/src/Network/WebSockets/WebSocketResources.pb.m deleted file mode 100644 index 1ac8b524c..000000000 --- a/SignalServiceKit/src/Network/WebSockets/WebSocketResources.pb.m +++ /dev/null @@ -1,1233 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! - -#import "WebSocketResources.pb.h" -// @@protoc_insertion_point(imports) - -@implementation WebSocketResourcesWebSocketResourcesRoot -static PBExtensionRegistry* extensionRegistry = nil; -+ (PBExtensionRegistry*) extensionRegistry { - return extensionRegistry; -} - -+ (void) initialize { - if (self == [WebSocketResourcesWebSocketResourcesRoot class]) { - PBMutableExtensionRegistry* registry = [PBMutableExtensionRegistry registry]; - [self registerAllExtensions:registry]; - [ObjectivecDescriptorRoot registerAllExtensions:registry]; - extensionRegistry = registry; - } -} -+ (void) registerAllExtensions:(PBMutableExtensionRegistry*) registry { -} -@end - -@interface WebSocketResourcesWebSocketRequestMessage () -@property (strong) NSString* verb; -@property (strong) NSString* path; -@property (strong) NSData* body; -@property (strong) NSMutableArray * headersArray; -@property UInt64 requestId; -@end - -@implementation WebSocketResourcesWebSocketRequestMessage - -- (BOOL) hasVerb { - return !!hasVerb_; -} -- (void) setHasVerb:(BOOL) _value_ { - hasVerb_ = !!_value_; -} -@synthesize verb; -- (BOOL) hasPath { - return !!hasPath_; -} -- (void) setHasPath:(BOOL) _value_ { - hasPath_ = !!_value_; -} -@synthesize path; -- (BOOL) hasBody { - return !!hasBody_; -} -- (void) setHasBody:(BOOL) _value_ { - hasBody_ = !!_value_; -} -@synthesize body; -@synthesize headersArray; -@dynamic headers; -- (BOOL) hasRequestId { - return !!hasRequestId_; -} -- (void) setHasRequestId:(BOOL) _value_ { - hasRequestId_ = !!_value_; -} -@synthesize requestId; -- (instancetype) init { - if ((self = [super init])) { - self.verb = @""; - self.path = @""; - self.body = [NSData data]; - self.requestId = 0L; - } - return self; -} -static WebSocketResourcesWebSocketRequestMessage* defaultWebSocketResourcesWebSocketRequestMessageInstance = nil; -+ (void) initialize { - if (self == [WebSocketResourcesWebSocketRequestMessage class]) { - defaultWebSocketResourcesWebSocketRequestMessageInstance = [[WebSocketResourcesWebSocketRequestMessage alloc] init]; - } -} -+ (instancetype) defaultInstance { - return defaultWebSocketResourcesWebSocketRequestMessageInstance; -} -- (instancetype) defaultInstance { - return defaultWebSocketResourcesWebSocketRequestMessageInstance; -} -- (NSArray *)headers { - return headersArray; -} -- (NSString*)headersAtIndex:(NSUInteger)index { - return [headersArray objectAtIndex:index]; -} -- (BOOL) isInitialized { - return YES; -} -- (void) writeToCodedOutputStream:(PBCodedOutputStream*) output { - if (self.hasVerb) { - [output writeString:1 value:self.verb]; - } - if (self.hasPath) { - [output writeString:2 value:self.path]; - } - if (self.hasBody) { - [output writeData:3 value:self.body]; - } - if (self.hasRequestId) { - [output writeUInt64:4 value:self.requestId]; - } - [self.headersArray enumerateObjectsUsingBlock:^(NSString *element, NSUInteger idx, BOOL *stop) { - [output writeString:5 value:element]; - }]; - [self.unknownFields writeToCodedOutputStream:output]; -} -- (SInt32) serializedSize { - __block SInt32 size_ = memoizedSerializedSize; - if (size_ != -1) { - return size_; - } - - size_ = 0; - if (self.hasVerb) { - size_ += computeStringSize(1, self.verb); - } - if (self.hasPath) { - size_ += computeStringSize(2, self.path); - } - if (self.hasBody) { - size_ += computeDataSize(3, self.body); - } - if (self.hasRequestId) { - size_ += computeUInt64Size(4, self.requestId); - } - { - __block SInt32 dataSize = 0; - const NSUInteger count = self.headersArray.count; - [self.headersArray enumerateObjectsUsingBlock:^(NSString *element, NSUInteger idx, BOOL *stop) { - dataSize += computeStringSizeNoTag(element); - }]; - size_ += dataSize; - size_ += (SInt32)(1 * count); - } - size_ += self.unknownFields.serializedSize; - memoizedSerializedSize = size_; - return size_; -} -+ (WebSocketResourcesWebSocketRequestMessage*) parseFromData:(NSData*) data { - return (WebSocketResourcesWebSocketRequestMessage*)[[[WebSocketResourcesWebSocketRequestMessage builder] mergeFromData:data] build]; -} -+ (WebSocketResourcesWebSocketRequestMessage*) parseFromData:(NSData*) data extensionRegistry:(PBExtensionRegistry*) extensionRegistry { - return (WebSocketResourcesWebSocketRequestMessage*)[[[WebSocketResourcesWebSocketRequestMessage builder] mergeFromData:data extensionRegistry:extensionRegistry] build]; -} -+ (WebSocketResourcesWebSocketRequestMessage*) parseFromInputStream:(NSInputStream*) input { - return (WebSocketResourcesWebSocketRequestMessage*)[[[WebSocketResourcesWebSocketRequestMessage builder] mergeFromInputStream:input] build]; -} -+ (WebSocketResourcesWebSocketRequestMessage*) parseFromInputStream:(NSInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry { - return (WebSocketResourcesWebSocketRequestMessage*)[[[WebSocketResourcesWebSocketRequestMessage builder] mergeFromInputStream:input extensionRegistry:extensionRegistry] build]; -} -+ (WebSocketResourcesWebSocketRequestMessage*) parseFromCodedInputStream:(PBCodedInputStream*) input { - return (WebSocketResourcesWebSocketRequestMessage*)[[[WebSocketResourcesWebSocketRequestMessage builder] mergeFromCodedInputStream:input] build]; -} -+ (WebSocketResourcesWebSocketRequestMessage*) parseFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry { - return (WebSocketResourcesWebSocketRequestMessage*)[[[WebSocketResourcesWebSocketRequestMessage builder] mergeFromCodedInputStream:input extensionRegistry:extensionRegistry] build]; -} -+ (WebSocketResourcesWebSocketRequestMessageBuilder*) builder { - return [[WebSocketResourcesWebSocketRequestMessageBuilder alloc] init]; -} -+ (WebSocketResourcesWebSocketRequestMessageBuilder*) builderWithPrototype:(WebSocketResourcesWebSocketRequestMessage*) prototype { - return [[WebSocketResourcesWebSocketRequestMessage builder] mergeFrom:prototype]; -} -- (WebSocketResourcesWebSocketRequestMessageBuilder*) builder { - return [WebSocketResourcesWebSocketRequestMessage builder]; -} -- (WebSocketResourcesWebSocketRequestMessageBuilder*) toBuilder { - return [WebSocketResourcesWebSocketRequestMessage builderWithPrototype:self]; -} -- (void) writeDescriptionTo:(NSMutableString*) output withIndent:(NSString*) indent { - if (self.hasVerb) { - [output appendFormat:@"%@%@: %@\n", indent, @"verb", self.verb]; - } - if (self.hasPath) { - [output appendFormat:@"%@%@: %@\n", indent, @"path", self.path]; - } - if (self.hasBody) { - [output appendFormat:@"%@%@: %@\n", indent, @"body", self.body]; - } - if (self.hasRequestId) { - [output appendFormat:@"%@%@: %@\n", indent, @"requestId", [NSNumber numberWithLongLong:self.requestId]]; - } - [self.headersArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - [output appendFormat:@"%@%@: %@\n", indent, @"headers", obj]; - }]; - [self.unknownFields writeDescriptionTo:output withIndent:indent]; -} -- (void) storeInDictionary:(NSMutableDictionary *)dictionary { - if (self.hasVerb) { - [dictionary setObject: self.verb forKey: @"verb"]; - } - if (self.hasPath) { - [dictionary setObject: self.path forKey: @"path"]; - } - if (self.hasBody) { - [dictionary setObject: self.body forKey: @"body"]; - } - if (self.hasRequestId) { - [dictionary setObject: [NSNumber numberWithLongLong:self.requestId] forKey: @"requestId"]; - } - [dictionary setObject:self.headers forKey: @"headers"]; - [self.unknownFields storeInDictionary:dictionary]; -} -- (BOOL) isEqual:(id)other { - if (other == self) { - return YES; - } - if (![other isKindOfClass:[WebSocketResourcesWebSocketRequestMessage class]]) { - return NO; - } - WebSocketResourcesWebSocketRequestMessage *otherMessage = other; - return - self.hasVerb == otherMessage.hasVerb && - (!self.hasVerb || [self.verb isEqual:otherMessage.verb]) && - self.hasPath == otherMessage.hasPath && - (!self.hasPath || [self.path isEqual:otherMessage.path]) && - self.hasBody == otherMessage.hasBody && - (!self.hasBody || [self.body isEqual:otherMessage.body]) && - self.hasRequestId == otherMessage.hasRequestId && - (!self.hasRequestId || self.requestId == otherMessage.requestId) && - [self.headersArray isEqualToArray:otherMessage.headersArray] && - (self.unknownFields == otherMessage.unknownFields || (self.unknownFields != nil && [self.unknownFields isEqual:otherMessage.unknownFields])); -} -- (NSUInteger) hash { - __block NSUInteger hashCode = 7; - if (self.hasVerb) { - hashCode = hashCode * 31 + [self.verb hash]; - } - if (self.hasPath) { - hashCode = hashCode * 31 + [self.path hash]; - } - if (self.hasBody) { - hashCode = hashCode * 31 + [self.body hash]; - } - if (self.hasRequestId) { - hashCode = hashCode * 31 + [[NSNumber numberWithLongLong:self.requestId] hash]; - } - [self.headersArray enumerateObjectsUsingBlock:^(NSString *element, NSUInteger idx, BOOL *stop) { - hashCode = hashCode * 31 + [element hash]; - }]; - hashCode = hashCode * 31 + [self.unknownFields hash]; - return hashCode; -} -@end - -@interface WebSocketResourcesWebSocketRequestMessageBuilder() -@property (strong) WebSocketResourcesWebSocketRequestMessage* resultWebSocketRequestMessage; -@end - -@implementation WebSocketResourcesWebSocketRequestMessageBuilder -@synthesize resultWebSocketRequestMessage; -- (instancetype) init { - if ((self = [super init])) { - self.resultWebSocketRequestMessage = [[WebSocketResourcesWebSocketRequestMessage alloc] init]; - } - return self; -} -- (PBGeneratedMessage*) internalGetResult { - return resultWebSocketRequestMessage; -} -- (WebSocketResourcesWebSocketRequestMessageBuilder*) clear { - self.resultWebSocketRequestMessage = [[WebSocketResourcesWebSocketRequestMessage alloc] init]; - return self; -} -- (WebSocketResourcesWebSocketRequestMessageBuilder*) clone { - return [WebSocketResourcesWebSocketRequestMessage builderWithPrototype:resultWebSocketRequestMessage]; -} -- (WebSocketResourcesWebSocketRequestMessage*) defaultInstance { - return [WebSocketResourcesWebSocketRequestMessage defaultInstance]; -} -- (WebSocketResourcesWebSocketRequestMessage*) build { - [self checkInitialized]; - return [self buildPartial]; -} -- (WebSocketResourcesWebSocketRequestMessage*) buildPartial { - WebSocketResourcesWebSocketRequestMessage* returnMe = resultWebSocketRequestMessage; - self.resultWebSocketRequestMessage = nil; - return returnMe; -} -- (WebSocketResourcesWebSocketRequestMessageBuilder*) mergeFrom:(WebSocketResourcesWebSocketRequestMessage*) other { - if (other == [WebSocketResourcesWebSocketRequestMessage defaultInstance]) { - return self; - } - if (other.hasVerb) { - [self setVerb:other.verb]; - } - if (other.hasPath) { - [self setPath:other.path]; - } - if (other.hasBody) { - [self setBody:other.body]; - } - if (other.headersArray.count > 0) { - if (resultWebSocketRequestMessage.headersArray == nil) { - resultWebSocketRequestMessage.headersArray = [[NSMutableArray alloc] initWithArray:other.headersArray]; - } else { - [resultWebSocketRequestMessage.headersArray addObjectsFromArray:other.headersArray]; - } - } - if (other.hasRequestId) { - [self setRequestId:other.requestId]; - } - [self mergeUnknownFields:other.unknownFields]; - return self; -} -- (WebSocketResourcesWebSocketRequestMessageBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input { - return [self mergeFromCodedInputStream:input extensionRegistry:[PBExtensionRegistry emptyRegistry]]; -} -- (WebSocketResourcesWebSocketRequestMessageBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry { - PBUnknownFieldSetBuilder* unknownFields = [PBUnknownFieldSet builderWithUnknownFields:self.unknownFields]; - while (YES) { - SInt32 tag = [input readTag]; - switch (tag) { - case 0: - [self setUnknownFields:[unknownFields build]]; - return self; - default: { - if (![self parseUnknownField:input unknownFields:unknownFields extensionRegistry:extensionRegistry tag:tag]) { - [self setUnknownFields:[unknownFields build]]; - return self; - } - break; - } - case 10: { - [self setVerb:[input readString]]; - break; - } - case 18: { - [self setPath:[input readString]]; - break; - } - case 26: { - [self setBody:[input readData]]; - break; - } - case 32: { - [self setRequestId:[input readUInt64]]; - break; - } - case 42: { - [self addHeaders:[input readString]]; - break; - } - } - } -} -- (BOOL) hasVerb { - return resultWebSocketRequestMessage.hasVerb; -} -- (NSString*) verb { - return resultWebSocketRequestMessage.verb; -} -- (WebSocketResourcesWebSocketRequestMessageBuilder*) setVerb:(NSString*) value { - resultWebSocketRequestMessage.hasVerb = YES; - resultWebSocketRequestMessage.verb = value; - return self; -} -- (WebSocketResourcesWebSocketRequestMessageBuilder*) clearVerb { - resultWebSocketRequestMessage.hasVerb = NO; - resultWebSocketRequestMessage.verb = @""; - return self; -} -- (BOOL) hasPath { - return resultWebSocketRequestMessage.hasPath; -} -- (NSString*) path { - return resultWebSocketRequestMessage.path; -} -- (WebSocketResourcesWebSocketRequestMessageBuilder*) setPath:(NSString*) value { - resultWebSocketRequestMessage.hasPath = YES; - resultWebSocketRequestMessage.path = value; - return self; -} -- (WebSocketResourcesWebSocketRequestMessageBuilder*) clearPath { - resultWebSocketRequestMessage.hasPath = NO; - resultWebSocketRequestMessage.path = @""; - return self; -} -- (BOOL) hasBody { - return resultWebSocketRequestMessage.hasBody; -} -- (NSData*) body { - return resultWebSocketRequestMessage.body; -} -- (WebSocketResourcesWebSocketRequestMessageBuilder*) setBody:(NSData*) value { - resultWebSocketRequestMessage.hasBody = YES; - resultWebSocketRequestMessage.body = value; - return self; -} -- (WebSocketResourcesWebSocketRequestMessageBuilder*) clearBody { - resultWebSocketRequestMessage.hasBody = NO; - resultWebSocketRequestMessage.body = [NSData data]; - return self; -} -- (NSMutableArray *)headers { - return resultWebSocketRequestMessage.headersArray; -} -- (NSString*)headersAtIndex:(NSUInteger)index { - return [resultWebSocketRequestMessage headersAtIndex:index]; -} -- (WebSocketResourcesWebSocketRequestMessageBuilder *)addHeaders:(NSString*)value { - if (resultWebSocketRequestMessage.headersArray == nil) { - resultWebSocketRequestMessage.headersArray = [[NSMutableArray alloc]init]; - } - [resultWebSocketRequestMessage.headersArray addObject:value]; - return self; -} -- (WebSocketResourcesWebSocketRequestMessageBuilder *)setHeadersArray:(NSArray *)array { - resultWebSocketRequestMessage.headersArray = [[NSMutableArray alloc] initWithArray:array]; - return self; -} -- (WebSocketResourcesWebSocketRequestMessageBuilder *)clearHeaders { - resultWebSocketRequestMessage.headersArray = nil; - return self; -} -- (BOOL) hasRequestId { - return resultWebSocketRequestMessage.hasRequestId; -} -- (UInt64) requestId { - return resultWebSocketRequestMessage.requestId; -} -- (WebSocketResourcesWebSocketRequestMessageBuilder*) setRequestId:(UInt64) value { - resultWebSocketRequestMessage.hasRequestId = YES; - resultWebSocketRequestMessage.requestId = value; - return self; -} -- (WebSocketResourcesWebSocketRequestMessageBuilder*) clearRequestId { - resultWebSocketRequestMessage.hasRequestId = NO; - resultWebSocketRequestMessage.requestId = 0L; - return self; -} -@end - -@interface WebSocketResourcesWebSocketResponseMessage () -@property UInt64 requestId; -@property UInt32 status; -@property (strong) NSString* message; -@property (strong) NSMutableArray * headersArray; -@property (strong) NSData* body; -@end - -@implementation WebSocketResourcesWebSocketResponseMessage - -- (BOOL) hasRequestId { - return !!hasRequestId_; -} -- (void) setHasRequestId:(BOOL) _value_ { - hasRequestId_ = !!_value_; -} -@synthesize requestId; -- (BOOL) hasStatus { - return !!hasStatus_; -} -- (void) setHasStatus:(BOOL) _value_ { - hasStatus_ = !!_value_; -} -@synthesize status; -- (BOOL) hasMessage { - return !!hasMessage_; -} -- (void) setHasMessage:(BOOL) _value_ { - hasMessage_ = !!_value_; -} -@synthesize message; -@synthesize headersArray; -@dynamic headers; -- (BOOL) hasBody { - return !!hasBody_; -} -- (void) setHasBody:(BOOL) _value_ { - hasBody_ = !!_value_; -} -@synthesize body; -- (instancetype) init { - if ((self = [super init])) { - self.requestId = 0L; - self.status = 0; - self.message = @""; - self.body = [NSData data]; - } - return self; -} -static WebSocketResourcesWebSocketResponseMessage* defaultWebSocketResourcesWebSocketResponseMessageInstance = nil; -+ (void) initialize { - if (self == [WebSocketResourcesWebSocketResponseMessage class]) { - defaultWebSocketResourcesWebSocketResponseMessageInstance = [[WebSocketResourcesWebSocketResponseMessage alloc] init]; - } -} -+ (instancetype) defaultInstance { - return defaultWebSocketResourcesWebSocketResponseMessageInstance; -} -- (instancetype) defaultInstance { - return defaultWebSocketResourcesWebSocketResponseMessageInstance; -} -- (NSArray *)headers { - return headersArray; -} -- (NSString*)headersAtIndex:(NSUInteger)index { - return [headersArray objectAtIndex:index]; -} -- (BOOL) isInitialized { - return YES; -} -- (void) writeToCodedOutputStream:(PBCodedOutputStream*) output { - if (self.hasRequestId) { - [output writeUInt64:1 value:self.requestId]; - } - if (self.hasStatus) { - [output writeUInt32:2 value:self.status]; - } - if (self.hasMessage) { - [output writeString:3 value:self.message]; - } - if (self.hasBody) { - [output writeData:4 value:self.body]; - } - [self.headersArray enumerateObjectsUsingBlock:^(NSString *element, NSUInteger idx, BOOL *stop) { - [output writeString:5 value:element]; - }]; - [self.unknownFields writeToCodedOutputStream:output]; -} -- (SInt32) serializedSize { - __block SInt32 size_ = memoizedSerializedSize; - if (size_ != -1) { - return size_; - } - - size_ = 0; - if (self.hasRequestId) { - size_ += computeUInt64Size(1, self.requestId); - } - if (self.hasStatus) { - size_ += computeUInt32Size(2, self.status); - } - if (self.hasMessage) { - size_ += computeStringSize(3, self.message); - } - if (self.hasBody) { - size_ += computeDataSize(4, self.body); - } - { - __block SInt32 dataSize = 0; - const NSUInteger count = self.headersArray.count; - [self.headersArray enumerateObjectsUsingBlock:^(NSString *element, NSUInteger idx, BOOL *stop) { - dataSize += computeStringSizeNoTag(element); - }]; - size_ += dataSize; - size_ += (SInt32)(1 * count); - } - size_ += self.unknownFields.serializedSize; - memoizedSerializedSize = size_; - return size_; -} -+ (WebSocketResourcesWebSocketResponseMessage*) parseFromData:(NSData*) data { - return (WebSocketResourcesWebSocketResponseMessage*)[[[WebSocketResourcesWebSocketResponseMessage builder] mergeFromData:data] build]; -} -+ (WebSocketResourcesWebSocketResponseMessage*) parseFromData:(NSData*) data extensionRegistry:(PBExtensionRegistry*) extensionRegistry { - return (WebSocketResourcesWebSocketResponseMessage*)[[[WebSocketResourcesWebSocketResponseMessage builder] mergeFromData:data extensionRegistry:extensionRegistry] build]; -} -+ (WebSocketResourcesWebSocketResponseMessage*) parseFromInputStream:(NSInputStream*) input { - return (WebSocketResourcesWebSocketResponseMessage*)[[[WebSocketResourcesWebSocketResponseMessage builder] mergeFromInputStream:input] build]; -} -+ (WebSocketResourcesWebSocketResponseMessage*) parseFromInputStream:(NSInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry { - return (WebSocketResourcesWebSocketResponseMessage*)[[[WebSocketResourcesWebSocketResponseMessage builder] mergeFromInputStream:input extensionRegistry:extensionRegistry] build]; -} -+ (WebSocketResourcesWebSocketResponseMessage*) parseFromCodedInputStream:(PBCodedInputStream*) input { - return (WebSocketResourcesWebSocketResponseMessage*)[[[WebSocketResourcesWebSocketResponseMessage builder] mergeFromCodedInputStream:input] build]; -} -+ (WebSocketResourcesWebSocketResponseMessage*) parseFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry { - return (WebSocketResourcesWebSocketResponseMessage*)[[[WebSocketResourcesWebSocketResponseMessage builder] mergeFromCodedInputStream:input extensionRegistry:extensionRegistry] build]; -} -+ (WebSocketResourcesWebSocketResponseMessageBuilder*) builder { - return [[WebSocketResourcesWebSocketResponseMessageBuilder alloc] init]; -} -+ (WebSocketResourcesWebSocketResponseMessageBuilder*) builderWithPrototype:(WebSocketResourcesWebSocketResponseMessage*) prototype { - return [[WebSocketResourcesWebSocketResponseMessage builder] mergeFrom:prototype]; -} -- (WebSocketResourcesWebSocketResponseMessageBuilder*) builder { - return [WebSocketResourcesWebSocketResponseMessage builder]; -} -- (WebSocketResourcesWebSocketResponseMessageBuilder*) toBuilder { - return [WebSocketResourcesWebSocketResponseMessage builderWithPrototype:self]; -} -- (void) writeDescriptionTo:(NSMutableString*) output withIndent:(NSString*) indent { - if (self.hasRequestId) { - [output appendFormat:@"%@%@: %@\n", indent, @"requestId", [NSNumber numberWithLongLong:self.requestId]]; - } - if (self.hasStatus) { - [output appendFormat:@"%@%@: %@\n", indent, @"status", [NSNumber numberWithInteger:self.status]]; - } - if (self.hasMessage) { - [output appendFormat:@"%@%@: %@\n", indent, @"message", self.message]; - } - if (self.hasBody) { - [output appendFormat:@"%@%@: %@\n", indent, @"body", self.body]; - } - [self.headersArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - [output appendFormat:@"%@%@: %@\n", indent, @"headers", obj]; - }]; - [self.unknownFields writeDescriptionTo:output withIndent:indent]; -} -- (void) storeInDictionary:(NSMutableDictionary *)dictionary { - if (self.hasRequestId) { - [dictionary setObject: [NSNumber numberWithLongLong:self.requestId] forKey: @"requestId"]; - } - if (self.hasStatus) { - [dictionary setObject: [NSNumber numberWithInteger:self.status] forKey: @"status"]; - } - if (self.hasMessage) { - [dictionary setObject: self.message forKey: @"message"]; - } - if (self.hasBody) { - [dictionary setObject: self.body forKey: @"body"]; - } - [dictionary setObject:self.headers forKey: @"headers"]; - [self.unknownFields storeInDictionary:dictionary]; -} -- (BOOL) isEqual:(id)other { - if (other == self) { - return YES; - } - if (![other isKindOfClass:[WebSocketResourcesWebSocketResponseMessage class]]) { - return NO; - } - WebSocketResourcesWebSocketResponseMessage *otherMessage = other; - return - self.hasRequestId == otherMessage.hasRequestId && - (!self.hasRequestId || self.requestId == otherMessage.requestId) && - self.hasStatus == otherMessage.hasStatus && - (!self.hasStatus || self.status == otherMessage.status) && - self.hasMessage == otherMessage.hasMessage && - (!self.hasMessage || [self.message isEqual:otherMessage.message]) && - self.hasBody == otherMessage.hasBody && - (!self.hasBody || [self.body isEqual:otherMessage.body]) && - [self.headersArray isEqualToArray:otherMessage.headersArray] && - (self.unknownFields == otherMessage.unknownFields || (self.unknownFields != nil && [self.unknownFields isEqual:otherMessage.unknownFields])); -} -- (NSUInteger) hash { - __block NSUInteger hashCode = 7; - if (self.hasRequestId) { - hashCode = hashCode * 31 + [[NSNumber numberWithLongLong:self.requestId] hash]; - } - if (self.hasStatus) { - hashCode = hashCode * 31 + [[NSNumber numberWithInteger:self.status] hash]; - } - if (self.hasMessage) { - hashCode = hashCode * 31 + [self.message hash]; - } - if (self.hasBody) { - hashCode = hashCode * 31 + [self.body hash]; - } - [self.headersArray enumerateObjectsUsingBlock:^(NSString *element, NSUInteger idx, BOOL *stop) { - hashCode = hashCode * 31 + [element hash]; - }]; - hashCode = hashCode * 31 + [self.unknownFields hash]; - return hashCode; -} -@end - -@interface WebSocketResourcesWebSocketResponseMessageBuilder() -@property (strong) WebSocketResourcesWebSocketResponseMessage* resultWebSocketResponseMessage; -@end - -@implementation WebSocketResourcesWebSocketResponseMessageBuilder -@synthesize resultWebSocketResponseMessage; -- (instancetype) init { - if ((self = [super init])) { - self.resultWebSocketResponseMessage = [[WebSocketResourcesWebSocketResponseMessage alloc] init]; - } - return self; -} -- (PBGeneratedMessage*) internalGetResult { - return resultWebSocketResponseMessage; -} -- (WebSocketResourcesWebSocketResponseMessageBuilder*) clear { - self.resultWebSocketResponseMessage = [[WebSocketResourcesWebSocketResponseMessage alloc] init]; - return self; -} -- (WebSocketResourcesWebSocketResponseMessageBuilder*) clone { - return [WebSocketResourcesWebSocketResponseMessage builderWithPrototype:resultWebSocketResponseMessage]; -} -- (WebSocketResourcesWebSocketResponseMessage*) defaultInstance { - return [WebSocketResourcesWebSocketResponseMessage defaultInstance]; -} -- (WebSocketResourcesWebSocketResponseMessage*) build { - [self checkInitialized]; - return [self buildPartial]; -} -- (WebSocketResourcesWebSocketResponseMessage*) buildPartial { - WebSocketResourcesWebSocketResponseMessage* returnMe = resultWebSocketResponseMessage; - self.resultWebSocketResponseMessage = nil; - return returnMe; -} -- (WebSocketResourcesWebSocketResponseMessageBuilder*) mergeFrom:(WebSocketResourcesWebSocketResponseMessage*) other { - if (other == [WebSocketResourcesWebSocketResponseMessage defaultInstance]) { - return self; - } - if (other.hasRequestId) { - [self setRequestId:other.requestId]; - } - if (other.hasStatus) { - [self setStatus:other.status]; - } - if (other.hasMessage) { - [self setMessage:other.message]; - } - if (other.headersArray.count > 0) { - if (resultWebSocketResponseMessage.headersArray == nil) { - resultWebSocketResponseMessage.headersArray = [[NSMutableArray alloc] initWithArray:other.headersArray]; - } else { - [resultWebSocketResponseMessage.headersArray addObjectsFromArray:other.headersArray]; - } - } - if (other.hasBody) { - [self setBody:other.body]; - } - [self mergeUnknownFields:other.unknownFields]; - return self; -} -- (WebSocketResourcesWebSocketResponseMessageBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input { - return [self mergeFromCodedInputStream:input extensionRegistry:[PBExtensionRegistry emptyRegistry]]; -} -- (WebSocketResourcesWebSocketResponseMessageBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry { - PBUnknownFieldSetBuilder* unknownFields = [PBUnknownFieldSet builderWithUnknownFields:self.unknownFields]; - while (YES) { - SInt32 tag = [input readTag]; - switch (tag) { - case 0: - [self setUnknownFields:[unknownFields build]]; - return self; - default: { - if (![self parseUnknownField:input unknownFields:unknownFields extensionRegistry:extensionRegistry tag:tag]) { - [self setUnknownFields:[unknownFields build]]; - return self; - } - break; - } - case 8: { - [self setRequestId:[input readUInt64]]; - break; - } - case 16: { - [self setStatus:[input readUInt32]]; - break; - } - case 26: { - [self setMessage:[input readString]]; - break; - } - case 34: { - [self setBody:[input readData]]; - break; - } - case 42: { - [self addHeaders:[input readString]]; - break; - } - } - } -} -- (BOOL) hasRequestId { - return resultWebSocketResponseMessage.hasRequestId; -} -- (UInt64) requestId { - return resultWebSocketResponseMessage.requestId; -} -- (WebSocketResourcesWebSocketResponseMessageBuilder*) setRequestId:(UInt64) value { - resultWebSocketResponseMessage.hasRequestId = YES; - resultWebSocketResponseMessage.requestId = value; - return self; -} -- (WebSocketResourcesWebSocketResponseMessageBuilder*) clearRequestId { - resultWebSocketResponseMessage.hasRequestId = NO; - resultWebSocketResponseMessage.requestId = 0L; - return self; -} -- (BOOL) hasStatus { - return resultWebSocketResponseMessage.hasStatus; -} -- (UInt32) status { - return resultWebSocketResponseMessage.status; -} -- (WebSocketResourcesWebSocketResponseMessageBuilder*) setStatus:(UInt32) value { - resultWebSocketResponseMessage.hasStatus = YES; - resultWebSocketResponseMessage.status = value; - return self; -} -- (WebSocketResourcesWebSocketResponseMessageBuilder*) clearStatus { - resultWebSocketResponseMessage.hasStatus = NO; - resultWebSocketResponseMessage.status = 0; - return self; -} -- (BOOL) hasMessage { - return resultWebSocketResponseMessage.hasMessage; -} -- (NSString*) message { - return resultWebSocketResponseMessage.message; -} -- (WebSocketResourcesWebSocketResponseMessageBuilder*) setMessage:(NSString*) value { - resultWebSocketResponseMessage.hasMessage = YES; - resultWebSocketResponseMessage.message = value; - return self; -} -- (WebSocketResourcesWebSocketResponseMessageBuilder*) clearMessage { - resultWebSocketResponseMessage.hasMessage = NO; - resultWebSocketResponseMessage.message = @""; - return self; -} -- (NSMutableArray *)headers { - return resultWebSocketResponseMessage.headersArray; -} -- (NSString*)headersAtIndex:(NSUInteger)index { - return [resultWebSocketResponseMessage headersAtIndex:index]; -} -- (WebSocketResourcesWebSocketResponseMessageBuilder *)addHeaders:(NSString*)value { - if (resultWebSocketResponseMessage.headersArray == nil) { - resultWebSocketResponseMessage.headersArray = [[NSMutableArray alloc]init]; - } - [resultWebSocketResponseMessage.headersArray addObject:value]; - return self; -} -- (WebSocketResourcesWebSocketResponseMessageBuilder *)setHeadersArray:(NSArray *)array { - resultWebSocketResponseMessage.headersArray = [[NSMutableArray alloc] initWithArray:array]; - return self; -} -- (WebSocketResourcesWebSocketResponseMessageBuilder *)clearHeaders { - resultWebSocketResponseMessage.headersArray = nil; - return self; -} -- (BOOL) hasBody { - return resultWebSocketResponseMessage.hasBody; -} -- (NSData*) body { - return resultWebSocketResponseMessage.body; -} -- (WebSocketResourcesWebSocketResponseMessageBuilder*) setBody:(NSData*) value { - resultWebSocketResponseMessage.hasBody = YES; - resultWebSocketResponseMessage.body = value; - return self; -} -- (WebSocketResourcesWebSocketResponseMessageBuilder*) clearBody { - resultWebSocketResponseMessage.hasBody = NO; - resultWebSocketResponseMessage.body = [NSData data]; - return self; -} -@end - -@interface WebSocketResourcesWebSocketMessage () -@property WebSocketResourcesWebSocketMessageType type; -@property (strong) WebSocketResourcesWebSocketRequestMessage* request; -@property (strong) WebSocketResourcesWebSocketResponseMessage* response; -@end - -@implementation WebSocketResourcesWebSocketMessage - -- (BOOL) hasType { - return !!hasType_; -} -- (void) setHasType:(BOOL) _value_ { - hasType_ = !!_value_; -} -@synthesize type; -- (BOOL) hasRequest { - return !!hasRequest_; -} -- (void) setHasRequest:(BOOL) _value_ { - hasRequest_ = !!_value_; -} -@synthesize request; -- (BOOL) hasResponse { - return !!hasResponse_; -} -- (void) setHasResponse:(BOOL) _value_ { - hasResponse_ = !!_value_; -} -@synthesize response; -- (instancetype) init { - if ((self = [super init])) { - self.type = WebSocketResourcesWebSocketMessageTypeUnknown; - self.request = [WebSocketResourcesWebSocketRequestMessage defaultInstance]; - self.response = [WebSocketResourcesWebSocketResponseMessage defaultInstance]; - } - return self; -} -static WebSocketResourcesWebSocketMessage* defaultWebSocketResourcesWebSocketMessageInstance = nil; -+ (void) initialize { - if (self == [WebSocketResourcesWebSocketMessage class]) { - defaultWebSocketResourcesWebSocketMessageInstance = [[WebSocketResourcesWebSocketMessage alloc] init]; - } -} -+ (instancetype) defaultInstance { - return defaultWebSocketResourcesWebSocketMessageInstance; -} -- (instancetype) defaultInstance { - return defaultWebSocketResourcesWebSocketMessageInstance; -} -- (BOOL) isInitialized { - return YES; -} -- (void) writeToCodedOutputStream:(PBCodedOutputStream*) output { - if (self.hasType) { - [output writeEnum:1 value:self.type]; - } - if (self.hasRequest) { - [output writeMessage:2 value:self.request]; - } - if (self.hasResponse) { - [output writeMessage:3 value:self.response]; - } - [self.unknownFields writeToCodedOutputStream:output]; -} -- (SInt32) serializedSize { - __block SInt32 size_ = memoizedSerializedSize; - if (size_ != -1) { - return size_; - } - - size_ = 0; - if (self.hasType) { - size_ += computeEnumSize(1, self.type); - } - if (self.hasRequest) { - size_ += computeMessageSize(2, self.request); - } - if (self.hasResponse) { - size_ += computeMessageSize(3, self.response); - } - size_ += self.unknownFields.serializedSize; - memoizedSerializedSize = size_; - return size_; -} -+ (WebSocketResourcesWebSocketMessage*) parseFromData:(NSData*) data { - return (WebSocketResourcesWebSocketMessage*)[[[WebSocketResourcesWebSocketMessage builder] mergeFromData:data] build]; -} -+ (WebSocketResourcesWebSocketMessage*) parseFromData:(NSData*) data extensionRegistry:(PBExtensionRegistry*) extensionRegistry { - return (WebSocketResourcesWebSocketMessage*)[[[WebSocketResourcesWebSocketMessage builder] mergeFromData:data extensionRegistry:extensionRegistry] build]; -} -+ (WebSocketResourcesWebSocketMessage*) parseFromInputStream:(NSInputStream*) input { - return (WebSocketResourcesWebSocketMessage*)[[[WebSocketResourcesWebSocketMessage builder] mergeFromInputStream:input] build]; -} -+ (WebSocketResourcesWebSocketMessage*) parseFromInputStream:(NSInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry { - return (WebSocketResourcesWebSocketMessage*)[[[WebSocketResourcesWebSocketMessage builder] mergeFromInputStream:input extensionRegistry:extensionRegistry] build]; -} -+ (WebSocketResourcesWebSocketMessage*) parseFromCodedInputStream:(PBCodedInputStream*) input { - return (WebSocketResourcesWebSocketMessage*)[[[WebSocketResourcesWebSocketMessage builder] mergeFromCodedInputStream:input] build]; -} -+ (WebSocketResourcesWebSocketMessage*) parseFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry { - return (WebSocketResourcesWebSocketMessage*)[[[WebSocketResourcesWebSocketMessage builder] mergeFromCodedInputStream:input extensionRegistry:extensionRegistry] build]; -} -+ (WebSocketResourcesWebSocketMessageBuilder*) builder { - return [[WebSocketResourcesWebSocketMessageBuilder alloc] init]; -} -+ (WebSocketResourcesWebSocketMessageBuilder*) builderWithPrototype:(WebSocketResourcesWebSocketMessage*) prototype { - return [[WebSocketResourcesWebSocketMessage builder] mergeFrom:prototype]; -} -- (WebSocketResourcesWebSocketMessageBuilder*) builder { - return [WebSocketResourcesWebSocketMessage builder]; -} -- (WebSocketResourcesWebSocketMessageBuilder*) toBuilder { - return [WebSocketResourcesWebSocketMessage builderWithPrototype:self]; -} -- (void) writeDescriptionTo:(NSMutableString*) output withIndent:(NSString*) indent { - if (self.hasType) { - [output appendFormat:@"%@%@: %@\n", indent, @"type", NSStringFromWebSocketResourcesWebSocketMessageType(self.type)]; - } - if (self.hasRequest) { - [output appendFormat:@"%@%@ {\n", indent, @"request"]; - [self.request writeDescriptionTo:output - withIndent:[NSString stringWithFormat:@"%@ ", indent]]; - [output appendFormat:@"%@}\n", indent]; - } - if (self.hasResponse) { - [output appendFormat:@"%@%@ {\n", indent, @"response"]; - [self.response writeDescriptionTo:output - withIndent:[NSString stringWithFormat:@"%@ ", indent]]; - [output appendFormat:@"%@}\n", indent]; - } - [self.unknownFields writeDescriptionTo:output withIndent:indent]; -} -- (void) storeInDictionary:(NSMutableDictionary *)dictionary { - if (self.hasType) { - [dictionary setObject: @(self.type) forKey: @"type"]; - } - if (self.hasRequest) { - NSMutableDictionary *messageDictionary = [NSMutableDictionary dictionary]; - [self.request storeInDictionary:messageDictionary]; - [dictionary setObject:[NSDictionary dictionaryWithDictionary:messageDictionary] forKey:@"request"]; - } - if (self.hasResponse) { - NSMutableDictionary *messageDictionary = [NSMutableDictionary dictionary]; - [self.response storeInDictionary:messageDictionary]; - [dictionary setObject:[NSDictionary dictionaryWithDictionary:messageDictionary] forKey:@"response"]; - } - [self.unknownFields storeInDictionary:dictionary]; -} -- (BOOL) isEqual:(id)other { - if (other == self) { - return YES; - } - if (![other isKindOfClass:[WebSocketResourcesWebSocketMessage class]]) { - return NO; - } - WebSocketResourcesWebSocketMessage *otherMessage = other; - return - self.hasType == otherMessage.hasType && - (!self.hasType || self.type == otherMessage.type) && - self.hasRequest == otherMessage.hasRequest && - (!self.hasRequest || [self.request isEqual:otherMessage.request]) && - self.hasResponse == otherMessage.hasResponse && - (!self.hasResponse || [self.response isEqual:otherMessage.response]) && - (self.unknownFields == otherMessage.unknownFields || (self.unknownFields != nil && [self.unknownFields isEqual:otherMessage.unknownFields])); -} -- (NSUInteger) hash { - __block NSUInteger hashCode = 7; - if (self.hasType) { - hashCode = hashCode * 31 + self.type; - } - if (self.hasRequest) { - hashCode = hashCode * 31 + [self.request hash]; - } - if (self.hasResponse) { - hashCode = hashCode * 31 + [self.response hash]; - } - hashCode = hashCode * 31 + [self.unknownFields hash]; - return hashCode; -} -@end - -BOOL WebSocketResourcesWebSocketMessageTypeIsValidValue(WebSocketResourcesWebSocketMessageType value) { - switch (value) { - case WebSocketResourcesWebSocketMessageTypeUnknown: - case WebSocketResourcesWebSocketMessageTypeRequest: - case WebSocketResourcesWebSocketMessageTypeResponse: - return YES; - default: - return NO; - } -} -NSString *NSStringFromWebSocketResourcesWebSocketMessageType(WebSocketResourcesWebSocketMessageType value) { - switch (value) { - case WebSocketResourcesWebSocketMessageTypeUnknown: - return @"WebSocketResourcesWebSocketMessageTypeUnknown"; - case WebSocketResourcesWebSocketMessageTypeRequest: - return @"WebSocketResourcesWebSocketMessageTypeRequest"; - case WebSocketResourcesWebSocketMessageTypeResponse: - return @"WebSocketResourcesWebSocketMessageTypeResponse"; - default: - return nil; - } -} - -@interface WebSocketResourcesWebSocketMessageBuilder() -@property (strong) WebSocketResourcesWebSocketMessage* resultWebSocketMessage; -@end - -@implementation WebSocketResourcesWebSocketMessageBuilder -@synthesize resultWebSocketMessage; -- (instancetype) init { - if ((self = [super init])) { - self.resultWebSocketMessage = [[WebSocketResourcesWebSocketMessage alloc] init]; - } - return self; -} -- (PBGeneratedMessage*) internalGetResult { - return resultWebSocketMessage; -} -- (WebSocketResourcesWebSocketMessageBuilder*) clear { - self.resultWebSocketMessage = [[WebSocketResourcesWebSocketMessage alloc] init]; - return self; -} -- (WebSocketResourcesWebSocketMessageBuilder*) clone { - return [WebSocketResourcesWebSocketMessage builderWithPrototype:resultWebSocketMessage]; -} -- (WebSocketResourcesWebSocketMessage*) defaultInstance { - return [WebSocketResourcesWebSocketMessage defaultInstance]; -} -- (WebSocketResourcesWebSocketMessage*) build { - [self checkInitialized]; - return [self buildPartial]; -} -- (WebSocketResourcesWebSocketMessage*) buildPartial { - WebSocketResourcesWebSocketMessage* returnMe = resultWebSocketMessage; - self.resultWebSocketMessage = nil; - return returnMe; -} -- (WebSocketResourcesWebSocketMessageBuilder*) mergeFrom:(WebSocketResourcesWebSocketMessage*) other { - if (other == [WebSocketResourcesWebSocketMessage defaultInstance]) { - return self; - } - if (other.hasType) { - [self setType:other.type]; - } - if (other.hasRequest) { - [self mergeRequest:other.request]; - } - if (other.hasResponse) { - [self mergeResponse:other.response]; - } - [self mergeUnknownFields:other.unknownFields]; - return self; -} -- (WebSocketResourcesWebSocketMessageBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input { - return [self mergeFromCodedInputStream:input extensionRegistry:[PBExtensionRegistry emptyRegistry]]; -} -- (WebSocketResourcesWebSocketMessageBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry { - PBUnknownFieldSetBuilder* unknownFields = [PBUnknownFieldSet builderWithUnknownFields:self.unknownFields]; - while (YES) { - SInt32 tag = [input readTag]; - switch (tag) { - case 0: - [self setUnknownFields:[unknownFields build]]; - return self; - default: { - if (![self parseUnknownField:input unknownFields:unknownFields extensionRegistry:extensionRegistry tag:tag]) { - [self setUnknownFields:[unknownFields build]]; - return self; - } - break; - } - case 8: { - WebSocketResourcesWebSocketMessageType value = (WebSocketResourcesWebSocketMessageType)[input readEnum]; - if (WebSocketResourcesWebSocketMessageTypeIsValidValue(value)) { - [self setType:value]; - } else { - [unknownFields mergeVarintField:1 value:value]; - } - break; - } - case 18: { - WebSocketResourcesWebSocketRequestMessageBuilder* subBuilder = [WebSocketResourcesWebSocketRequestMessage builder]; - if (self.hasRequest) { - [subBuilder mergeFrom:self.request]; - } - [input readMessage:subBuilder extensionRegistry:extensionRegistry]; - [self setRequest:[subBuilder buildPartial]]; - break; - } - case 26: { - WebSocketResourcesWebSocketResponseMessageBuilder* subBuilder = [WebSocketResourcesWebSocketResponseMessage builder]; - if (self.hasResponse) { - [subBuilder mergeFrom:self.response]; - } - [input readMessage:subBuilder extensionRegistry:extensionRegistry]; - [self setResponse:[subBuilder buildPartial]]; - break; - } - } - } -} -- (BOOL) hasType { - return resultWebSocketMessage.hasType; -} -- (WebSocketResourcesWebSocketMessageType) type { - return resultWebSocketMessage.type; -} -- (WebSocketResourcesWebSocketMessageBuilder*) setType:(WebSocketResourcesWebSocketMessageType) value { - resultWebSocketMessage.hasType = YES; - resultWebSocketMessage.type = value; - return self; -} -- (WebSocketResourcesWebSocketMessageBuilder*) clearType { - resultWebSocketMessage.hasType = NO; - resultWebSocketMessage.type = WebSocketResourcesWebSocketMessageTypeUnknown; - return self; -} -- (BOOL) hasRequest { - return resultWebSocketMessage.hasRequest; -} -- (WebSocketResourcesWebSocketRequestMessage*) request { - return resultWebSocketMessage.request; -} -- (WebSocketResourcesWebSocketMessageBuilder*) setRequest:(WebSocketResourcesWebSocketRequestMessage*) value { - resultWebSocketMessage.hasRequest = YES; - resultWebSocketMessage.request = value; - return self; -} -- (WebSocketResourcesWebSocketMessageBuilder*) setRequestBuilder:(WebSocketResourcesWebSocketRequestMessageBuilder*) builderForValue { - return [self setRequest:[builderForValue build]]; -} -- (WebSocketResourcesWebSocketMessageBuilder*) mergeRequest:(WebSocketResourcesWebSocketRequestMessage*) value { - if (resultWebSocketMessage.hasRequest && - resultWebSocketMessage.request != [WebSocketResourcesWebSocketRequestMessage defaultInstance]) { - resultWebSocketMessage.request = - [[[WebSocketResourcesWebSocketRequestMessage builderWithPrototype:resultWebSocketMessage.request] mergeFrom:value] buildPartial]; - } else { - resultWebSocketMessage.request = value; - } - resultWebSocketMessage.hasRequest = YES; - return self; -} -- (WebSocketResourcesWebSocketMessageBuilder*) clearRequest { - resultWebSocketMessage.hasRequest = NO; - resultWebSocketMessage.request = [WebSocketResourcesWebSocketRequestMessage defaultInstance]; - return self; -} -- (BOOL) hasResponse { - return resultWebSocketMessage.hasResponse; -} -- (WebSocketResourcesWebSocketResponseMessage*) response { - return resultWebSocketMessage.response; -} -- (WebSocketResourcesWebSocketMessageBuilder*) setResponse:(WebSocketResourcesWebSocketResponseMessage*) value { - resultWebSocketMessage.hasResponse = YES; - resultWebSocketMessage.response = value; - return self; -} -- (WebSocketResourcesWebSocketMessageBuilder*) setResponseBuilder:(WebSocketResourcesWebSocketResponseMessageBuilder*) builderForValue { - return [self setResponse:[builderForValue build]]; -} -- (WebSocketResourcesWebSocketMessageBuilder*) mergeResponse:(WebSocketResourcesWebSocketResponseMessage*) value { - if (resultWebSocketMessage.hasResponse && - resultWebSocketMessage.response != [WebSocketResourcesWebSocketResponseMessage defaultInstance]) { - resultWebSocketMessage.response = - [[[WebSocketResourcesWebSocketResponseMessage builderWithPrototype:resultWebSocketMessage.response] mergeFrom:value] buildPartial]; - } else { - resultWebSocketMessage.response = value; - } - resultWebSocketMessage.hasResponse = YES; - return self; -} -- (WebSocketResourcesWebSocketMessageBuilder*) clearResponse { - resultWebSocketMessage.hasResponse = NO; - resultWebSocketMessage.response = [WebSocketResourcesWebSocketResponseMessage defaultInstance]; - return self; -} -@end - - -// @@protoc_insertion_point(global_scope) diff --git a/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift b/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift index 0b4933ff0..fea71afbf 100644 --- a/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift +++ b/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift @@ -208,8 +208,6 @@ public enum WebSocketProtoError: Error { @objc public let status: UInt32 - @objc public let body: Data - @objc public var message: String? { guard proto.hasMessage else { return nil @@ -224,14 +222,22 @@ public enum WebSocketProtoError: Error { return proto.headers } + @objc public var body: Data? { + guard proto.hasBody else { + return nil + } + return proto.body + } + @objc public var hasBody: Bool { + return proto.hasBody + } + private init(proto: WebSocketProtos_WebSocketResponseMessage, requestID: UInt64, - status: UInt32, - body: Data) { + status: UInt32) { self.proto = proto self.requestID = requestID self.status = status - self.body = body } // NOTE: This method is intended for debugging purposes only. @@ -264,19 +270,13 @@ public enum WebSocketProtoError: Error { } let status = proto.status - guard proto.hasBody else { - throw WebSocketProtoError.invalidProtobuf(description: "\(logTag) missing required field: body") - } - let body = proto.body - // MARK: - Begin Validation Logic for WebSocketProtoWebSocketResponseMessage - // MARK: - End Validation Logic for WebSocketProtoWebSocketResponseMessage - let result = WebSocketProtoWebSocketResponseMessage(proto: proto, requestID: requestID, - status: status, - body: body) + status: status) return result } } diff --git a/SignalServiceKit/src/Protos/Generated/WebSocketResources.pb.swift b/SignalServiceKit/src/Protos/Generated/WebSocketResources.pb.swift index dde0f11fa..1ad5aa630 100644 --- a/SignalServiceKit/src/Protos/Generated/WebSocketResources.pb.swift +++ b/SignalServiceKit/src/Protos/Generated/WebSocketResources.pb.swift @@ -1,10 +1,6 @@ -// DO NOT EDIT. // -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: WebSocketResources.proto +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // -// For information on using the generated types, please see the documenation: -// https://github.com/apple/swift-protobuf/ //* // Copyright (C) 2014-2016 Open Whisper Systems @@ -22,7 +18,7 @@ import SwiftProtobuf // incompatible with the version of SwiftProtobuf to which you are linking. // Please ensure that your are building against the same version of the API // that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} typealias Version = _2 } @@ -77,10 +73,10 @@ struct WebSocketProtos_WebSocketRequestMessage { init() {} - fileprivate var _verb: String? = nil - fileprivate var _path: String? = nil - fileprivate var _body: Data? = nil - fileprivate var _requestID: UInt64? = nil + fileprivate var _verb: String? + fileprivate var _path: String? + fileprivate var _body: Data? + fileprivate var _requestID: UInt64? } struct WebSocketProtos_WebSocketResponseMessage { @@ -119,7 +115,6 @@ struct WebSocketProtos_WebSocketResponseMessage { var headers: [String] = [] - /// @required var body: Data { get {return _body ?? SwiftProtobuf.Internal.emptyData} set {_body = newValue} @@ -133,10 +128,10 @@ struct WebSocketProtos_WebSocketResponseMessage { init() {} - fileprivate var _requestID: UInt64? = nil - fileprivate var _status: UInt32? = nil - fileprivate var _message: String? = nil - fileprivate var _body: Data? = nil + fileprivate var _requestID: UInt64? + fileprivate var _status: UInt32? + fileprivate var _message: String? + fileprivate var _body: Data? } struct WebSocketProtos_WebSocketMessage { @@ -210,7 +205,7 @@ struct WebSocketProtos_WebSocketMessage { // MARK: - Code below here is support for the SwiftProtobuf runtime. -fileprivate let _protobuf_package = "WebSocketProtos" +private let _protobuf_package = "WebSocketProtos" extension WebSocketProtos_WebSocketRequestMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = _protobuf_package + ".WebSocketRequestMessage" @@ -219,7 +214,7 @@ extension WebSocketProtos_WebSocketRequestMessage: SwiftProtobuf.Message, SwiftP 2: .same(proto: "path"), 3: .same(proto: "body"), 5: .same(proto: "headers"), - 4: .same(proto: "requestId"), + 4: .same(proto: "requestId") ] mutating func decodeMessage(decoder: inout D) throws { @@ -272,7 +267,7 @@ extension WebSocketProtos_WebSocketResponseMessage: SwiftProtobuf.Message, Swift 2: .same(proto: "status"), 3: .same(proto: "message"), 5: .same(proto: "headers"), - 4: .same(proto: "body"), + 4: .same(proto: "body") ] mutating func decodeMessage(decoder: inout D) throws { @@ -323,13 +318,13 @@ extension WebSocketProtos_WebSocketMessage: SwiftProtobuf.Message, SwiftProtobuf static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .same(proto: "type"), 2: .same(proto: "request"), - 3: .same(proto: "response"), + 3: .same(proto: "response") ] fileprivate class _StorageClass { - var _type: WebSocketProtos_WebSocketMessage.TypeEnum? = nil - var _request: WebSocketProtos_WebSocketRequestMessage? = nil - var _response: WebSocketProtos_WebSocketResponseMessage? = nil + var _type: WebSocketProtos_WebSocketMessage.TypeEnum? + var _request: WebSocketProtos_WebSocketRequestMessage? + var _response: WebSocketProtos_WebSocketResponseMessage? static let defaultInstance = _StorageClass() @@ -399,6 +394,6 @@ extension WebSocketProtos_WebSocketMessage.TypeEnum: SwiftProtobuf._ProtoNamePro static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 0: .same(proto: "UNKNOWN"), 1: .same(proto: "REQUEST"), - 2: .same(proto: "RESPONSE"), + 2: .same(proto: "RESPONSE") ] }