message.py 1.0 KB

12345678910111213141516171819202122232425
  1. from direct.distributed.DistributedObject import DistributedObject
  2. from direct.showbase.MessengerGlobal import messenger
  3. class Message(DistributedObject):
  4. def __init__(self, clientRepo):
  5. DistributedObject.__init__(self, clientRepo)
  6. def sendText(self, messageText):
  7. """Function which is caled for local changes only"""
  8. # send an event, which will set the text on the
  9. #print "got a message"
  10. messenger.send("setText", [messageText])
  11. def d_sendText(self, messageText):
  12. """Function which is caled to send the message over the network
  13. therfore the d_ suffix stands for distributed"""
  14. #print "send message %s" % messageText
  15. self.sendUpdate("sendText", [messageText])
  16. def b_sendText(self, messageText):
  17. """Function which combines the local and distributed functionality,
  18. so the sendText and d_sendText functions are called.
  19. The b_ suffix stands for both"""
  20. self.sendText(messageText)
  21. self.d_sendText(messageText)