-
Notifications
You must be signed in to change notification settings - Fork 7
/
PacketRecieved.m
42 lines (34 loc) · 956 Bytes
/
PacketRecieved.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// PacketRecieved.m
// Snap
//
// Created by Abdullah Bakhach on 10/9/12.
// Copyright (c) 2012 Hollance. All rights reserved.
//
#import "PacketRecieved.h"
#import "NSData+SnapAdditions.h"
@implementation PacketRecieved
@synthesize packetNumber = _packetNumber;
+ (id)packetWithData:(NSData *)data
{
UInt32 packetNumber = [[NSData dataWithBytes:(void *)([data bytes]+PACKET_HEADER_SIZE)
length:sizeof(UInt32)] rw_int32AtOffset:0];
return [[self class] packetWithNumber:packetNumber];
}
+ (id)packetWithNumber:(UInt32)packetNumber
{
return [[[self class] alloc] initWithNumber:packetNumber];
}
- (id)initWithNumber:(UInt32)packetNumber
{
if ((self = [super initWithType:PacketTypeReceived]))
{
self.packetNumber = packetNumber;
}
return self;
}
- (void)addPayloadToData:(NSMutableData *)data
{
[data rw_appendInt32:self.packetNumber];
}
@end