Alex Bikfalvi
SimStream Documentation
HostFlow.h
00001 #pragma once 00002 00003 #include "Node.h" 00004 #include "ConnectionLayer.h" 00005 00006 class CHostFlow : public CNode 00007 { 00008 private: 00009 // Connections layer 00010 CConnectionLayer* connectionLayer; 00011 00012 // Delegates 00013 Delegate4<CHostFlow, void, __uint32, CPacketIp*, CPacketUdp*, CPacket*>* 00014 delegateRecv; 00015 00016 Delegate2<CHostFlow, void, CConnectionReceiver*, CPacket*>* 00017 delegateConnectionRecv; 00018 Delegate2<CHostFlow, bool, CAddress, CPacket*>* 00019 delegateAccept; 00020 Delegate1<CHostFlow, void, CConnectionSender*>* 00021 delegateAccepted; 00022 00023 Delegate2<CHostFlow, void, CConnection*, CConnection::EOpenResult>* 00024 delegateOpen; 00025 Delegate2<CHostFlow, void, CConnection*, CConnection::ECloseResult>* 00026 delegateClose; 00027 00028 00029 // Connections 00030 CConnectionSender* senders[2]; 00031 CConnectionReceiver* receiver; 00032 __uint8 senderIndex; 00033 00034 00035 // Timer 00036 CTimer<CHostFlow>* timers[2]; 00037 00038 // Info 00039 __bitrate streamRate; 00040 double packetRate; 00041 __time packetInterval; 00042 __uint32 packetSize; 00043 __uint32 connectionsMax; 00044 __uint16 port; 00045 __uint32 packetIndex[2]; 00046 __uint32 packets; 00047 00048 // Data 00049 FILE* fileSender; 00050 FILE* fileReceiver; 00051 00052 // Delegates 00053 Delegate2<CHostFlow, void, CConnectionSender*, CPacket*>* 00054 delegateSenderSend; 00055 00056 public: 00057 CHostFlow( 00058 __uint32 id, 00059 CSimHandler* sim, 00060 CAddress address, 00061 CInfo* info 00062 ); 00063 virtual ~CHostFlow(); 00064 00065 void Connect(CAddress dst); 00066 void DisconnectSender(__uint8 sender); 00067 void DisconnectReceiver(); 00068 00069 void StartFlow(__uint8 sender); 00070 void StopFlow(__uint8 sender); 00071 00072 virtual void Finalize(); 00073 00074 private: 00075 void Recv(__uint32 entry, CPacketIp* ip, CPacketUdp* udp, CPacket* packet); 00076 00077 void ConnectionRecv(CConnectionReceiver* connection, CPacket* packet); 00078 bool ConnectionAccept(CAddress src, CPacket* packet); 00079 void ConnectionAccepted(CConnectionSender* connection); 00080 00081 void ConnectionOpen(CConnection* connection, CConnection::EOpenResult result); 00082 void ConnectionClose(CConnection* connection, CConnection::ECloseResult result); 00083 00084 void SenderSend(CConnectionSender* sender, CPacket* packet); 00085 00086 void Timer(CTimerInfo* info); 00087 };
Last updated: February 8, 2011