Alex Bikfalvi
SimStream Documentation
HostClientPull.cpp
00001 #include "Headers.h" 00002 #include "HostClientPull.h" 00003 #include "Debug.h" 00004 00005 CHostClientPull::CHostClientPull( 00006 __uint32 id, 00007 CSimHandler* sim, 00008 CAddress address, 00009 CInfoPull* info, 00010 CData* data, 00011 __bitrate bw 00012 ) : CHostClient(id, sim, address, info, data, bw) 00013 { 00014 // Global 00015 this->info = info; 00016 00017 // Delegates 00018 this->delegateRecv = new Delegate4<CHostClientPull, void, __uint32, CPacketIp*, CPacketUdp*, CPacket*>(this, &CHostClientPull::Recv); 00019 this->delegateLink = new Delegate0<CHostClientPull, CLink*>(this, &CHostClientPull::Link); 00020 00021 // Stream client push 00022 this->streamClient = new CStreamClientPull( 00023 this->sim, 00024 this->info, 00025 this->address, 00026 this->layerUdp->DelegateSend(), 00027 this->layerIgmp->DelegateJoin(), 00028 this->layerIgmp->DelegateLeave(), 00029 this->delegateLink, 00030 0); 00031 00032 // Create layer connections 00033 // Layer UDP -> this 00034 (*this->layerUdp->EventRecv()) += this->delegateRecv; 00035 } 00036 00037 CHostClientPull::~CHostClientPull() 00038 { 00039 // Client 00040 delete this->streamClient; 00041 00042 // Delegates 00043 delete this->delegateRecv; 00044 delete this->delegateLink; 00045 } 00046 00047 void CHostClientPull::ChannelConnectMcast(CChannel* channel) 00048 { 00049 // Start the client 00050 this->streamClient->Start(channel); 00051 00052 #ifdef MULTICAST 00053 // Multicast statistics 00054 this->info->MulticastJoin(this->id, channel->Id()); 00055 #endif 00056 } 00057 00058 void CHostClientPull::ChannelDisconnectMcast() 00059 { 00060 // Stop the client 00061 this->streamClient->Stop(); 00062 00063 #ifdef MULTICAST 00064 // Multicast statistics 00065 this->info->MulticastLeave(this->id, channel->Id()); 00066 #endif 00067 } 00068 00069 void CHostClientPull::ChannelConnectUcast(CChannel* channel) 00070 { 00071 // Start the client 00072 this->streamClient->Start(channel); 00073 } 00074 00075 void CHostClientPull::ChannelDisconnectUcast() 00076 { 00077 // Stop the client 00078 this->streamClient->Stop(); 00079 } 00080 00081 void CHostClientPull::Recv(__uint32 entry, CPacketIp* ip, CPacketUdp* udp, CPacket* packet) 00082 { 00083 // Process the received packets with the client 00084 this->streamClient->Recv(ip->Src(), ip->Dst(), udp->Src(), udp->Dst(), packet); 00085 } 00086 00087 00088 void CHostClientPull::SendStream(CAddress dst, CPacketStream* packet) 00089 { 00090 // Send the stream packet to the UDP layer (TTL = 128) 00091 // (*this->layerUdp->DelegateSend())(this->info->PortStream(), this->info->PortStream(), dst, 128, packet); 00092 } 00093 00094 void CHostClientPull::SendMessage(CAddress dst, CStreamMessage* message) 00095 { 00096 // Send the message packet to the UDP layer (TTL = 128) 00097 // (*this->layerUdp->DelegateSend())(this->info->PortControl(), this->info->PortControl(), dst, 128, message); 00098 } 00099 00100 void CHostClientPull::Finalize() 00101 { 00102 // Call base class finalizer 00103 CHostClient::Finalize(); 00104 00105 // Call client finalizer 00106 this->streamClient->Finalize(); 00107 }
Last updated: February 8, 2011