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