--------------------------------------------------------------------------
| 564 | |
| 565 | //-------------------------------------------------------------------------- |
| 566 | void MessageVector::registerSpectator(SpectatorCallback callBack, void *spectatorKey) |
| 567 | { |
| 568 | AssertFatal(callBack != NULL, "Error, must have a callback!"); |
| 569 | |
| 570 | // First, make sure that this hasn't been registered already... |
| 571 | U32 i; |
| 572 | for (i = 0; i < mSpectators.size(); i++) { |
| 573 | AssertFatal(mSpectators[i].key != spectatorKey, "Error, spectator key already registered!"); |
| 574 | if (mSpectators[i].key == spectatorKey) |
| 575 | return; |
| 576 | } |
| 577 | |
| 578 | mSpectators.increment(); |
| 579 | SpectatorRef& lastSpectatorRef = mSpectators.last(); |
| 580 | lastSpectatorRef.callback = callBack; |
| 581 | lastSpectatorRef.key = spectatorKey; |
| 582 | |
| 583 | // Need to message this spectator of all the lines currently inserted... |
| 584 | for (i = 0; i < mMessageLines.size(); i++) { |
| 585 | (*lastSpectatorRef.callback)(lastSpectatorRef.key, |
| 586 | LineInserted, i); |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | void MessageVector::unregisterSpectator(void * spectatorKey) |
| 591 | { |