00001 00009 #ifndef EVENTNET_H 00010 #define EVENTNET_H 00011 00012 #include "Event.H" 00013 00014 // ID's for NetMessages 00015 #define EVENTNETMSG_TYPE 1101 00016 #define EVENTBUFFERNETMSG_TYPE 1102 00017 00018 namespace VRG3D { 00019 00021 class EventNetMsg 00022 { 00023 public: 00024 EventNetMsg(EventRef e) { event = e; } 00025 EventNetMsg() {} 00026 00027 virtual ~EventNetMsg() {} 00028 00029 G3D::uint32 type() const { return EVENTNETMSG_TYPE; } 00030 00031 void serialize(BinaryOutput &b) const { 00032 alwaysAssertM(event.notNull(), "Null event in serialize method."); 00033 event->serialize(b); 00034 } 00035 00036 void deserialize(BinaryInput &b) { 00037 event = new Event("temp-name"); 00038 event->deserialize(b); 00039 } 00040 EventRef event; 00041 }; 00042 00043 00045 class EventBufferNetMsg 00046 { 00047 public: 00048 EventBufferNetMsg(const Array<EventRef> &msgEventBuffer) { 00049 eventBuffer = msgEventBuffer; 00050 } 00051 EventBufferNetMsg() {}; 00052 00053 virtual ~EventBufferNetMsg() {}; 00054 00055 G3D::uint32 type() const { return EVENTBUFFERNETMSG_TYPE; } 00056 00057 void serialize(BinaryOutput &b) const { 00058 b.writeInt32(eventBuffer.size()); 00059 for (int i=0;i<eventBuffer.size();i++) { 00060 eventBuffer[i]->serialize(b); 00061 } 00062 } 00063 00064 void deserialize(BinaryInput &b) { 00065 int32 numEvents = b.readInt32(); 00066 for (int i=0;i<numEvents;i++) { 00067 EventRef e = new Event("temp-name"); 00068 e->deserialize(b); 00069 eventBuffer.append(e); 00070 } 00071 } 00072 00073 Array<EventRef> eventBuffer; 00074 }; 00075 00076 00077 } // end namespace 00078 00079 #endif 00080