Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 20, 2010, 11:33:07 AM (15 years ago)
Author:
scheusso
Message:

mergine chat2 into presentation merger branch

Location:
code/branches/presentation3
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation3

  • code/branches/presentation3/src/libraries/network/ChatListener.cc

    r5781 r6928  
    3636        RegisterRootObject(ChatListener);
    3737    }
     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
    3848}
    3949
  • code/branches/presentation3/src/libraries/network/ChatListener.h

    r5781 r6928  
    3838    {
    3939        public:
     40            /* constructor, destructor */
    4041            ChatListener();
    4142            virtual ~ChatListener() {}
    4243
     44            /* What to do with incoming chat */
    4345            virtual void incomingChat(const std::string& message, unsigned int senderID) = 0;
    4446    };
  • code/branches/presentation3/src/libraries/network/Host.h

    r6073 r6928  
    4949class _NetworkExport Host{
    5050  private:
    51     //TODO add theese functions or adequate
     51    //TODO add these functions or adequate
    5252    //virtual bool processChat(packet::Chat *message, unsigned int clientID)=0;
    5353    //virtual bool sendChat(packet::Chat *chat)=0;
  • code/branches/presentation3/src/libraries/network/packet/Chat.cc

    r6417 r6928  
    3737
    3838#define   PACKET_FLAGS_CHAT PacketFlag::Reliable
     39
     40/* Some lengths */
    3941#define   _PACKETID         0
    4042const int _PLAYERID     =   _PACKETID + sizeof(Type::Value);
     
    4547 : Packet()
    4648{
     49  /* Add chat flag to packet flags */
    4750  flags_ = flags_ | PACKET_FLAGS_CHAT;
     51
     52  /* set message length to length of input string + 1 */
    4853  messageLength_ = message.length()+1;
     54
     55  /* allocate memory for the data */
    4956  data_=new unsigned char[ getSize() ];
     57
    5058  *(Type::Value *)(data_ + _PACKETID ) = Type::Chat;
    5159  *(unsigned int *)(data_ + _PLAYERID ) = playerID;
    5260  *(unsigned int *)(data_ + _MESSAGELENGTH ) = messageLength_;
     61
     62  /* cast the hell out of the message string, and copy it into the
     63   * data buffer.
     64   */
    5365  memcpy( data_+_MESSAGE, static_cast<void*>(const_cast<char*>(message.c_str())), messageLength_ );
    5466}
  • code/branches/presentation3/src/libraries/network/packet/Chat.h

    r6073 r6928  
    4141{
    4242public:
     43  /* constructors */
    4344  Chat( const std::string& message, unsigned int playerID );
    4445  Chat( uint8_t* data, unsigned int clientID );
     46
     47  /* destructor */
    4548  ~Chat();
    4649
     50  /* get size of packet */
    4751  inline unsigned int getSize() const;
     52
     53  /* process chat message packet and remove it afterwards */
    4854  bool process();
    4955
     56  /* Get the length of the message (not the full size of the packet) */
    5057  unsigned int getMessageLength(){ return messageLength_; };
     58
     59  /* return message content */
    5160  unsigned char *getMessage();
     61
    5262private:
     63
     64  /* Message length */
    5365  uint32_t messageLength_;
     66
     67  /* Client ID (an integral value for identification) */
    5468  unsigned int clientID_;
    5569};
Note: See TracChangeset for help on using the changeset viewer.