TAILIEUCHUNG - iPhone Cool Projects phần 4

Trước tiên, hãy nói một chút về lịch sử của nó. Frenzic là khá cũ, tôi phải thú nhận. Tôi đã có ý tưởng cơ bản cho Frenzic cách đây khoảng 18 năm, trong khi xem một chương trình trò chơi cheesy tương tự như Wheel of Fortune. Chương trình tham gia quay một bánh xe lớn với một quả bóng bên trong hạ cánh trên giá trị tiền cho thí sinh | CHAPTER 2 Mike Ash s Deep Dive Into Peer-to-Peer Networking 49 continue if CFSwapInt32BigToHost kSphereNetPositionPacketType continue This is all nice and simple since we only take one datatype. If we took more than one the length check would get a bit more complex and we d have to take different actions based on the datatype field. Since we re accepting only one datatype we can simply go back to the top of the loop if it isn t that one. The next thing to do is to notify the delegate. We don t want to notify the delegate directly though since we re not on the main thread and that could cause all kinds of trouble. Instead we ll bundle up the appropriate data and then bounce the call over to the main thread and call the delegate from there NSAutoreleasePool pool NSAutoreleasePool alloc init NSData packetData NSData dataWithBytes packet length sizeof packet NSData addressData NSData dataWithBytes addr length socklen NSArray arguments NSArray arrayWithObjects packetData addressData nil SEL mainThreadSEL @selector mainThreadReceivedPositionPacket self performSelectorOnMainThread mainThreadSEL withObject arguments waitUntilDone YES pool release The implementation of -mainThreadReceivedPositionPacket is straightforward. Unpack the arguments build a SphereNetSphereUpdate from the packet information and then notify the delegate - void mainThreadReceivedPositionPacket NSArray arguments extract the objects from the array created above NSData packetData arguments objectAtIndex 0 NSData addressData arguments objectAtIndex 1 const PositionPacket packet packetData bytes SphereNetSphereUpdate update .and update the SphereNetSphereUpdate struct float packet- r float packet- g float packet- b 50 CHAPTER 2 Mike Ash s Deep Dive Into Peer-to-Peer Networking .accounting for differences in endianness int32_t x CFSwapInt32BigToHost packet- x int32_t y CFSwapInt32BigToHost packet- y CGPointMake x y .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.