Alex Bikfalvi
SimStream Documentation
StreamDecoderFrame.cpp
00001 #include "Headers.h" 00002 #include "StreamDecoderFrame.h" 00003 #include "PacketStreamFrame.h" 00004 00005 CStreamDecoderFrame::CStreamDecoderFrame( 00006 IDelegate2<void, CAddress, CStreamFrame>* delegateRecv 00007 ) : CStreamDecoder() 00008 { 00009 assert(delegateRecv); 00010 00011 this->delegateRecv = delegateRecv; 00012 } 00013 00014 CStreamDecoderFrame::CStreamDecoderFrame( 00015 __uint32 stream, 00016 IDelegate2<void, CAddress, CStreamFrame>* delegateRecv 00017 ) : CStreamDecoder(stream) 00018 { 00019 assert(delegateRecv); 00020 00021 this->delegateRecv = delegateRecv; 00022 } 00023 00024 CStreamDecoder::EResult CStreamDecoderFrame::Decode(CAddress address, CPacketStream* packet) 00025 { 00026 assert(packet); 00027 00028 // Verify the packet is a frame packet 00029 if(packet->StreamType() != CPacketStream::STREAM_TYPE_FRAME) return FAIL_PACKET_TYPE; 00030 00031 // Validate the packet 00032 if(packet->Stream() != this->stream) return FAIL_STREAM; 00033 00034 // Receive the packet through the delegate 00035 (*this->delegateRecv)(address, type_cast<CPacketStreamFrame*>(packet)->Frame()); 00036 00037 return SUCCESS; 00038 }
Last updated: February 8, 2011