RemoteEvents.h
Go to the documentation of this file.00001 #ifndef _REMOTEEVENTS_H_
00002 #define _REMOTEEVENTS_H_
00003
00004 #include "Wireless/Socket.h"
00005 #include "Wireless/Wireless.h"
00006 #include "Wireless/SocketListener.h"
00007 #include "Events/EventBase.h"
00008 #include "Events/NetworkBuffer.h"
00009 #include "Shared/RemoteState.h"
00010 #include <vector>
00011 #include <string>
00012
00013
00014
00015
00016
00017
00018 class RemoteEvents : public SocketListener {
00019 public:
00020
00021
00022
00023 enum BufferType {
00024 Invalid,
00025 StateData,
00026 EventData,
00027 RequestData
00028 };
00029
00030
00031
00032 enum RequestType {
00033 EventListenerRequest,
00034 StateUpdateRequest,
00035 RemoveEventListenerRequest,
00036 StopStateUpdateRequest
00037 };
00038
00039
00040 bool isConnected();
00041
00042
00043 std::string remoteIPString();
00044
00045
00046 int remoteIPInt();
00047
00048
00049 static const int defaultBufferSize = 1024;
00050
00051 protected:
00052
00053
00054 RemoteEvents();
00055 virtual ~RemoteEvents();
00056
00057 Socket *sck;
00058
00059
00060 int sizeLeft;
00061 std::vector<char> vecbuf;
00062 BufferType bufType;
00063
00064 bool readSize(char* &data, int &bytes);
00065 bool readType(char* &data, int &bytes);
00066 bool readData(char* &data, int &bytes);
00067
00068
00069 RemoteEvents(RemoteEvents&);
00070 RemoteEvents &operator=(const RemoteEvents&);
00071 };
00072
00073
00074
00075 struct RemoteRequest {
00076 RemoteEvents::RequestType type;
00077
00078
00079 int numElements;
00080 EventBase::EventGeneratorID_t egid;
00081 size_t sid;
00082 EventBase::EventTypeID_t etid;
00083
00084
00085 RemoteState::StateType sType;
00086 unsigned int interval;
00087 };
00088
00089 std::ostream& operator<<(std::ostream &os, const RemoteRequest &req);
00090
00091 #endif