The Application Kit Table of Contents     The Application Kit Index

BMessageRunner

Derived from: (none)

Declared in: be/app/MessageRunner.h

Library: libbe.so

Allocation: Constructor only

Summary

The BMessageRunner class provides a handy mechanism for automatically sending an arbitrary message to a BMessenger at specified intervals. The application that creates the BMessageRunner can specify the message, the BMessenger to send the message to, how often to send the message, and how many times it should be sent.

The system roster handles actually dispatching the messages to the appropriate BMessengers at the desired time intervals; this class simply acts as an intermediary through which your application asks the roster to schedule sending the messages.


Constructor and Destructor


BMessageRunner()

                                                         
  

BMessageRunner(BMessenger target, const BMessage *message,
      bigtime_t interval, int32 count = -1)

BMessageRunner(BMessenger target, const BMessage *message,
      bigtime_t interval, int32 count, BMessenger replyTo)

Tells the roster to send the specified message to the target BMessenger every interval microseconds. The message will be sent count times (if count is -1, the message will be sent forever, or until the BMessageRunner is reconfigured or deleted).

The second form of the constructor lets the application specify, in replyTo, the BMessenger to which replies to the message should be sent.

The BMessageRunner can be reconfigured (to change the interval or count) by calling SetInterval() and SetCount().

After constructing a BMessageRunner, you should call InitCheck() to ensure that the object was created properly.


~BMessageRunner()

                                                         
  

virtual ~BMessageRunner()

Asks the roster to stop sending the message.


Member Functions


GetInfo()

                                                         
  

status_t GetInfo(bigtime_t *interval, int32 *count) const

GetInfo() returns in interval the time in microseconds that will pass between messages being sent, and in count the number of times the message will be sent.

RETURN CODES

B_OK. Information returned successfully.

  • B_NAME_NOT_FOUND. The roster returned invalid information about the BMessenger.

  • B_BAD_VALUE. The roster returned invalid information about the BMessenger.

  • Other errors. In general, getting an error back from this function is a bad thing.


    InitCheck()

                                                             
      

    status_t InitCheck(void) const

    InitCheck() returns a result code indicating B_OK if the BMessageRunner constructor executed sucessfully, or some other value if an error occurred setting up the object. You should call this immediately after creating a BMessageRunner, and shouldn't use the object if this function returns anything but B_OK.


    SetCount() , SetInterval()

                                                             
      

    status_t SetCount(int32 count)

    status_t SetInterval(bigtime_t interval)

    SetCount() sets the number of times the BMessageRunner will send the message. If you want the message to be sent forever (until the object is deleted or SetCount() is called again), specify -1.

    SetInterval() sets the number of microseconds that will pass between messages being sent.


    The Application Kit Table of Contents     The Application Kit Index


    The Be Book,
    ...in lovely HTML...
    for BeOS Release 5.

    Copyright © 2000 Be, Inc. All rights reserved..