Changeset 6928 for code/branches/presentation3/src/libraries
- Timestamp:
- May 20, 2010, 11:33:07 AM (15 years ago)
- Location:
- code/branches/presentation3
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3
- Property svn:mergeinfo changed
-
code/branches/presentation3/src/libraries/network/ChatListener.cc
r5781 r6928 36 36 RegisterRootObject(ChatListener); 37 37 } 38 39 //void ChatListener::incomingChat( const std::string& message, 40 //unsigned int senderID ) 41 //{ 42 //COUT(0) << "Chat: \"" << message << "\"\n"; 43 44 45 //} 46 47 38 48 } 39 49 -
code/branches/presentation3/src/libraries/network/ChatListener.h
r5781 r6928 38 38 { 39 39 public: 40 /* constructor, destructor */ 40 41 ChatListener(); 41 42 virtual ~ChatListener() {} 42 43 44 /* What to do with incoming chat */ 43 45 virtual void incomingChat(const std::string& message, unsigned int senderID) = 0; 44 46 }; -
code/branches/presentation3/src/libraries/network/Host.h
r6073 r6928 49 49 class _NetworkExport Host{ 50 50 private: 51 //TODO add the ese functions or adequate51 //TODO add these functions or adequate 52 52 //virtual bool processChat(packet::Chat *message, unsigned int clientID)=0; 53 53 //virtual bool sendChat(packet::Chat *chat)=0; -
code/branches/presentation3/src/libraries/network/packet/Chat.cc
r6417 r6928 37 37 38 38 #define PACKET_FLAGS_CHAT PacketFlag::Reliable 39 40 /* Some lengths */ 39 41 #define _PACKETID 0 40 42 const int _PLAYERID = _PACKETID + sizeof(Type::Value); … … 45 47 : Packet() 46 48 { 49 /* Add chat flag to packet flags */ 47 50 flags_ = flags_ | PACKET_FLAGS_CHAT; 51 52 /* set message length to length of input string + 1 */ 48 53 messageLength_ = message.length()+1; 54 55 /* allocate memory for the data */ 49 56 data_=new unsigned char[ getSize() ]; 57 50 58 *(Type::Value *)(data_ + _PACKETID ) = Type::Chat; 51 59 *(unsigned int *)(data_ + _PLAYERID ) = playerID; 52 60 *(unsigned int *)(data_ + _MESSAGELENGTH ) = messageLength_; 61 62 /* cast the hell out of the message string, and copy it into the 63 * data buffer. 64 */ 53 65 memcpy( data_+_MESSAGE, static_cast<void*>(const_cast<char*>(message.c_str())), messageLength_ ); 54 66 } -
code/branches/presentation3/src/libraries/network/packet/Chat.h
r6073 r6928 41 41 { 42 42 public: 43 /* constructors */ 43 44 Chat( const std::string& message, unsigned int playerID ); 44 45 Chat( uint8_t* data, unsigned int clientID ); 46 47 /* destructor */ 45 48 ~Chat(); 46 49 50 /* get size of packet */ 47 51 inline unsigned int getSize() const; 52 53 /* process chat message packet and remove it afterwards */ 48 54 bool process(); 49 55 56 /* Get the length of the message (not the full size of the packet) */ 50 57 unsigned int getMessageLength(){ return messageLength_; }; 58 59 /* return message content */ 51 60 unsigned char *getMessage(); 61 52 62 private: 63 64 /* Message length */ 53 65 uint32_t messageLength_; 66 67 /* Client ID (an integral value for identification) */ 54 68 unsigned int clientID_; 55 69 };
Note: See TracChangeset
for help on using the changeset viewer.