Panda3D
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Messenger Class Reference
Inheritance diagram for Messenger:
NetMessenger

Public Member Functions

def __init__ (self)
 
def __repr__ (self)
 
def accept (self, event, object, method, extraArgs=[], persistent=1)
 
def clear (self)
 
def detailedRepr (self)
 
def find (self, needle)
 
def findAll (self, needle, limit=None)
 
def future (self, event)
 
def getAllAccepting (self, object)
 
def getEvents (self)
 
def ignore (self, event, object)
 
def ignoreAll (self, object)
 
def isAccepting (self, event, object)
 
def isEmpty (self)
 
def isIgnoring (self, event, object)
 
def quiet (self, message)
 
def replaceMethod (self, oldMethod, newFunction)
 
def send (self, event, sentArgs=[], taskChain=None)
 
def toggleVerbose (self)
 
def unquiet (self, message)
 
def unwatch (self, needle)
 
def watch (self, needle)
 
def whoAccepts (self, event)
 

Public Attributes

 lock
 
 quieting
 

Static Public Attributes

def detailed_repr = detailedRepr
 
def find_all = findAll
 
def get_all_accepting = getAllAccepting
 
def get_events = getEvents
 
def ignore_all = ignoreAll
 
def is_accepting = isAccepting
 
def is_empty = isEmpty
 
def is_ignoring = isIgnoring
 
 notify = DirectNotifyGlobal.directNotify.newCategory("Messenger")
 
def replace_method = replaceMethod
 
def toggle_verbose = toggleVerbose
 
def who_accepts = whoAccepts
 

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)
One is keyed off the event name. It has the following structure:
    {event1: {object1: [method, extraArgs, persistent],
       object2: [method, extraArgs, persistent]},
     event2: {object1: [method, extraArgs, persistent],
       object2: [method, extraArgs, persistent]}}

This dictionary allow for efficient callbacks when the messenger
hears an event.

A second dictionary remembers which objects are accepting which
events. This allows for efficient ignoreAll commands.


Or, for an example with more real data:
    {'mouseDown': {avatar: [avatar.jump, [2.0], 1]}}

Member Function Documentation

◆ __repr__()

def __repr__ (   self)
Compact version of event, acceptor pairs

◆ accept()

def accept (   self,
  event,
  object,
  method,
  extraArgs = [],
  persistent = 1 
)
accept(self, string, DirectObject, Function, List, Boolean)

Make this object accept this event. When the event is
sent (using Messenger.send or from C++), method will be executed,
optionally passing in extraArgs.

If the persistent flag is set, it will continue to respond
to this event, otherwise it will respond only once.

◆ clear()

def clear (   self)
Start fresh with a clear dict

Reimplemented in NetMessenger.

◆ detailedRepr()

def detailedRepr (   self)
Print out the table in a detailed readable format

◆ find()

def find (   self,
  needle 
)
return a matching event (needle) if found (in haystack).
This is primarily a debugging tool.

◆ findAll()

def findAll (   self,
  needle,
  limit = None 
)
return a dict of events (needle) if found (in haystack).
limit may be None or an integer (e.g. 1).
This is primarily a debugging tool.

◆ future()

def future (   self,
  event 
)
Returns a future that is triggered by the given event name.  This
will function only once. 

◆ getAllAccepting()

def getAllAccepting (   self,
  object 
)
Returns the list of all events accepted by the indicated object.

◆ getEvents()

def getEvents (   self)

◆ ignore()

def ignore (   self,
  event,
  object 
)
ignore(self, string, DirectObject)
Make this object no longer respond to this event.
It is safe to call even if it was not already accepting

◆ ignoreAll()

def ignoreAll (   self,
  object 
)
Make this object no longer respond to any events it was accepting
Useful for cleanup

◆ isAccepting()

def isAccepting (   self,
  event,
  object 
)
isAccepting(self, string, DirectOject)
Is this object accepting this event?

◆ isEmpty()

def isEmpty (   self)

◆ isIgnoring()

def isIgnoring (   self,
  event,
  object 
)
isIgnorning(self, string, DirectObject)
Is this object ignoring this event?

◆ quiet()

def quiet (   self,
  message 
)
When verbose mode is on, don't spam the output with messages
marked as quiet.
This is primarily a debugging tool.

This is intended for debugging use only.
This function is not defined if python is ran with -O (optimize).

See Also: unquiet

◆ replaceMethod()

def replaceMethod (   self,
  oldMethod,
  newFunction 
)
This is only used by Finder.py - the module that lets
you redefine functions with Control-c-Control-v

◆ send()

def send (   self,
  event,
  sentArgs = [],
  taskChain = None 
)
Send this event, optionally passing in arguments

event is usually a string.
sentArgs is a list of any data that you want passed along to the
    handlers listening to this event.

If taskChain is not None, it is the name of the task chain
which should receive the event.  If taskChain is None, the
event is handled immediately.  Setting a non-None taskChain
will defer the event (possibly till next frame or even later)
and create a new, temporary task within the named taskChain,
but this is the only way to send an event across threads.

◆ toggleVerbose()

def toggleVerbose (   self)

◆ unquiet()

def unquiet (   self,
  message 
)
Remove a message from the list of messages that are not reported
in verbose mode.
This is primarily a debugging tool.

This is intended for debugging use only.
This function is not defined if python is ran with -O (optimize).

See Also: quiet

◆ unwatch()

def unwatch (   self,
  needle 
)
return a matching event (needle) if found (in haystack).
This is primarily a debugging tool.

This is intended for debugging use only.
This function is not defined if python is ran with -O (optimize).

See Also: watch

◆ watch()

def watch (   self,
  needle 
)
return a matching event (needle) if found (in haystack).
This is primarily a debugging tool.

This is intended for debugging use only.
This function is not defined if python is ran with -O (optimize).

See Also: unwatch

◆ whoAccepts()

def whoAccepts (   self,
  event 
)
Return objects accepting the given event

Member Data Documentation

◆ detailed_repr

def detailed_repr = detailedRepr
static

◆ find_all

def find_all = findAll
static

◆ get_all_accepting

def get_all_accepting = getAllAccepting
static

◆ get_events

def get_events = getEvents
static

◆ ignore_all

def ignore_all = ignoreAll
static

◆ is_accepting

def is_accepting = isAccepting
static

◆ is_empty

def is_empty = isEmpty
static

◆ is_ignoring

def is_ignoring = isIgnoring
static

◆ lock

lock

◆ notify

notify = DirectNotifyGlobal.directNotify.newCategory("Messenger")
static

◆ quieting

quieting

◆ replace_method

def replace_method = replaceMethod
static

◆ toggle_verbose

def toggle_verbose = toggleVerbose
static

◆ who_accepts

def who_accepts = whoAccepts
static