mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
718 B
Matlab
32 lines
718 B
Matlab
11 years ago
|
#import "PacketHandler.h"
|
||
|
#import "Constraints.h"
|
||
|
|
||
|
@implementation PacketHandler
|
||
|
|
||
|
@synthesize dataHandler, errorHandler;
|
||
|
|
||
|
+(PacketHandler*) packetHandler:(PacketHandlerBlock)dataHandler
|
||
|
withErrorHandler:(ErrorHandlerBlock)errorHandler {
|
||
|
|
||
|
require(dataHandler != nil);
|
||
|
require(errorHandler != nil);
|
||
|
|
||
|
PacketHandler* p = [PacketHandler new];
|
||
|
p->dataHandler = [dataHandler copy];
|
||
|
p->errorHandler = [errorHandler copy];
|
||
|
return p;
|
||
|
}
|
||
|
|
||
|
-(void) handlePacket:(id)packet {
|
||
|
dataHandler(packet);
|
||
|
}
|
||
|
|
||
|
-(void) handleError:(id)error
|
||
|
relatedInfo:(id)relatedInfo
|
||
|
causedTermination:(bool)causedTermination {
|
||
|
|
||
|
errorHandler(error, relatedInfo, causedTermination);
|
||
|
}
|
||
|
|
||
|
@end
|