Alex Bikfalvi
SimStream Documentation
StreamServerPull.h
00001 #pragma once 00002 00003 #include "StreamServer.h" 00004 #include "StreamBootPull.h" 00005 #include "InfoPull.h" 00006 #include "Timer.h" 00007 #include "Link.h" 00008 #include "PacketStream.h" 00009 #include "ConnectionLayer.h" 00010 00011 #include "StreamPullSender.h" 00012 #include "StreamPullReceiver.h" 00013 00014 #include "StreamMessageBootPullRequest.h" 00015 #include "StreamMessageBootPullResponse.h" 00016 #include "StreamMessageBootPullRegister.h" 00017 #include "StreamMessageBootPullDeregister.h" 00018 00019 #include "StreamMessagePullBitmapRequest.h" 00020 #include "StreamMessagePullBitmapResponse.h" 00021 #include "StreamMessagePullSegmentRequest.h" 00022 #include "StreamMessagePullSegmentResponse.h" 00023 00024 class CStreamServerPull : public CStreamServer 00025 { 00026 private: 00027 typedef map<__uint32, CStreamPullReceiver*> TReceiverList; 00028 00029 // Info 00030 CInfoPull* info; 00031 00032 // Bootstrap 00033 CStreamBootPull* bootstraps; 00034 00035 // Delegates 00036 IDelegate5<void, __uint16, __uint16, CAddress, __byte, CPacket*>* 00037 delegateSend; 00038 00039 Delegate2<CStreamServerPull, void, CConnectionReceiver*, CPacket*>* 00040 delegateConnectionRecv; 00041 Delegate2<CStreamServerPull, bool, CAddress, CPacket*>* 00042 delegateConnectionAccept; 00043 Delegate1<CStreamServerPull, void, CConnectionSender*>* 00044 delegateConnectionAccepted; 00045 00046 Delegate2<CStreamServerPull, void, CConnection*, CConnection::EOpenResult>* 00047 delegateConnectionSenderOpen; 00048 Delegate2<CStreamServerPull, void, CConnection*, CConnection::ECloseResult>* 00049 delegateConnectionSenderClose; 00050 00051 IDelegate0<CLink*>* delegateLink; 00052 00053 // Connection 00054 CConnectionLayer* connectionLayer; 00055 00056 // Stream 00057 TReceiverList receivers; 00058 00059 public: 00060 CStreamServerPull( 00061 CSimHandler* sim, 00062 CInfoPull* info, 00063 IDelegate5<void, __uint16, __uint16, CAddress, __byte, CPacket*>* delegateSend, 00064 IDelegate0<CLink*>* delegateLink 00065 ); 00066 virtual ~CStreamServerPull(); 00067 00068 // Control 00069 void Start(); 00070 void Stop(); 00071 00072 // Receive 00073 void Recv(CAddress srcAddress, __uint16 srcPort, __uint16 dstPort, CPacket* packet); 00074 00075 // Finalizer 00076 virtual void Finalize(); 00077 00078 private: 00079 void Timer(CTimerInfo* info); 00080 00081 00082 void RecvMessage(CAddress src, CStreamMessage* message); 00083 void RecvMessageQuery(CAddress src, CStreamMessageBootPullRequest* message); 00084 void RecvMessageRegister(CAddress src, CStreamMessageBootPullRegister* message); 00085 void RecvMessageDeregister(CAddress src, CStreamMessageBootPullDeregister* message); 00086 void RecvMessageBitmapRequest(CAddress src, CStreamMessagePullBitmapRequest* message); 00087 void RecvMessageSegmentRequest(CAddress src, CStreamMessagePullSegmentRequest* message); 00088 00089 void RecvConnection(CAddress srcAddress, __uint16 srcPort, __uint16 dstPort, CPacketConnection* packet); 00090 00091 void SendMessage(CAddress dst, CStreamMessage* message); 00092 00093 void ConnectionRecv(CConnectionReceiver* receiver, CPacket* packet); 00094 bool ConnectionAccept(CAddress src, CPacket* packet); 00095 void ConnectionAccepted(CConnectionSender* sender); 00096 00097 void ConnectionSenderOpen(CConnection* sender, CConnection::EOpenResult result); 00098 void ConnectionSenderClose(CConnection* sender, CConnection::ECloseResult result); 00099 };
Last updated: February 8, 2011