![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
Peer to peer synchronized ready and unready events. More...
#include <ReadyEvent.h>
Inheritance diagram for RakNet::ReadyEvent:Classes | |
| struct | ReadyEventNode |
| struct | RemoteSystem |
Public Member Functions | |
| bool | AddToWaitList (int eventId, SystemAddress address) |
| bool | DeleteEvent (int eventId) |
| bool | ForceCompletion (int eventId) |
| int | GetEventAtIndex (unsigned index) const |
| unsigned | GetEventListSize (void) const |
| SystemAddress | GetFromWaitListAtIndex (int eventId, unsigned index) const |
| ReadyEventSystemStatus | GetReadyStatus (int eventId, SystemAddress address) |
| unsigned | GetRemoteWaitListSize (int eventId) const |
| bool | HasEvent (int eventId) |
| bool | IsEventCompleted (int eventId) const |
| bool | IsEventCompletionProcessing (int eventId) const |
| bool | IsEventSet (int eventId) |
| bool | IsInWaitList (int eventId, SystemAddress address) |
| ReadyEvent () | |
| bool | RemoveFromWaitList (int eventId, SystemAddress address) |
| bool | SetEvent (int eventId, bool isReady) |
| void | SetSendChannel (unsigned char newChannel) |
| virtual | ~ReadyEvent () |
Static Public Member Functions | |
| static void | DestroyInstance (ReadyEvent *i) |
| static ReadyEvent * | GetInstance (void) |
| static int | ReadyEventNodeComp (const int &key, ReadyEvent::ReadyEventNode *const &data) |
| static int | RemoteSystemCompBySystemAddress (const SystemAddress &key, const RemoteSystem &data) |
Protected Member Functions | |
| bool | AddToWaitListInternal (unsigned eventIndex, SystemAddress address) |
| void | BroadcastReadyUpdate (unsigned eventIndex, bool forceIfNotDefault) |
| void | Clear (void) |
| unsigned | CreateNewEvent (int eventId, bool isReady) |
| bool | IsEventCompletedByIndex (unsigned eventIndex) const |
| virtual void | OnClosedConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason) |
| virtual void | OnRakPeerShutdown (void) |
| Called when RakPeer is shutdown. | |
| void | OnReadyEventForceAllSet (Packet *packet) |
| void | OnReadyEventPacketUpdate (Packet *packet) |
| void | OnReadyEventQuery (Packet *packet) |
| virtual PluginReceiveResult | OnReceive (Packet *packet) |
| void | PushCompletionPacket (unsigned eventId) |
| void | RemoveFromAllLists (SystemAddress address) |
| void | SendReadyStateQuery (unsigned eventId, SystemAddress address) |
| void | SendReadyUpdate (unsigned eventIndex, unsigned systemIndex, bool forceIfNotDefault) |
| bool | SetEventByIndex (int eventIndex, bool isReady) |
| void | UpdateReadyStatus (unsigned eventIndex) |
Protected Attributes | |
| unsigned char | channel |
| DataStructures::OrderedList < int, ReadyEventNode *, ReadyEvent::ReadyEventNodeComp > | readyEventNodeList |
For peer to peer networks in a fully connected mesh.
Solves the problem of how to tell if all peers, relative to all other peers, are in a certain ready state.
For example, if A is connected to B and C, A may see that B and C are ready, but does not know if B is ready to C, or vice-versa.
This plugin uses two stages to solve that problem, first, everyone I know about is ready. Second, everyone I know about is ready to everyone they know about.
The user will get ID_READY_EVENT_SET and ID_READY_EVENT_UNSET as the signal flag is set or unset
The user will get ID_READY_EVENT_ALL_SET when all systems are done waiting for all other systems, in which case the event is considered complete, and no longer tracked.
Definition at line 55 of file ReadyEvent.h.
| RakNet::ReadyEvent::ReadyEvent | ( | ) |
| virtual RakNet::ReadyEvent::~ReadyEvent | ( | ) | [virtual] |
| bool RakNet::ReadyEvent::AddToWaitList | ( | int | eventId, |
| SystemAddress | address | ||
| ) |
Adds a system to wait for to signal an event before considering the event complete and returning ID_READY_EVENT_ALL_SET. As we add systems, if this event was previously set to true with SetEvent, these systems will get ID_READY_EVENT_SET. As these systems disconnect (directly or indirectly through the router) they are removed.
| [in] | eventId | A user-defined number previously passed to SetEvent that has not yet completed |
| [in] | addressArray | An address to wait for event replies from. Pass UNASSIGNED_SYSTEM_ADDRESS for all currently connected systems. Until all systems in this list have called SetEvent with this ID and true, and have this system in the list, we won't get ID_READY_EVENT_COMPLETE |
| bool RakNet::ReadyEvent::AddToWaitListInternal | ( | unsigned | eventIndex, |
| SystemAddress | address | ||
| ) | [protected] |
| void RakNet::ReadyEvent::BroadcastReadyUpdate | ( | unsigned | eventIndex, |
| bool | forceIfNotDefault | ||
| ) | [protected] |
| void RakNet::ReadyEvent::Clear | ( | void | ) | [protected] |
| unsigned RakNet::ReadyEvent::CreateNewEvent | ( | int | eventId, |
| bool | isReady | ||
| ) | [protected] |
| bool RakNet::ReadyEvent::DeleteEvent | ( | int | eventId | ) |
Deletes an event. We will no longer wait for this event, and any systems that we know have set the event will be forgotten. Call this to clear memory when events are completed and you know you will never need them again.
| [in] | eventId | A user-defined identifier |
| static void RakNet::ReadyEvent::DestroyInstance | ( | ReadyEvent * | i | ) | [static] |
| bool RakNet::ReadyEvent::ForceCompletion | ( | int | eventId | ) |
When systems can call SetEvent() with isReady==false, it is possible for one system to return true from IsEventCompleted() while the other systems return false This can occur if a system SetEvent() with isReady==false while the completion message is still being transmitted. If your game has the situation where some action should be taken on all systems when IsEventCompleted() is true for any system, then call ForceCompletion() when the action begins. This will force all systems to return true from IsEventCompleted().
| [in] | eventId | A user-defined identifier to immediately set as completed |
| int RakNet::ReadyEvent::GetEventAtIndex | ( | unsigned | index | ) | const |
Returns the event ID stored at a particular index. EventIDs are stored sorted from least to greatest.
| [in] | index | Index into the array, from 0 to GetEventListSize() |
| unsigned RakNet::ReadyEvent::GetEventListSize | ( | void | ) | const |
Returns the total number of events stored in the system.
| SystemAddress RakNet::ReadyEvent::GetFromWaitListAtIndex | ( | int | eventId, |
| unsigned | index | ||
| ) | const |
Returns the system address of a system at a particular index, for this event.
| [in] | eventId | A user-defined identifier |
| [in] | index | Index into the array, from 0 to GetWaitListSize() |
| static ReadyEvent* RakNet::ReadyEvent::GetInstance | ( | void | ) | [static] |
| ReadyEventSystemStatus RakNet::ReadyEvent::GetReadyStatus | ( | int | eventId, |
| SystemAddress | address | ||
| ) |
For a remote system, find out what their ready status is (waiting, signaled, complete).
| [in] | eventId | A user-defined identifier |
| [in] | address | Which system we are checking up on |
| unsigned RakNet::ReadyEvent::GetRemoteWaitListSize | ( | int | eventId | ) | const |
Returns the total number of systems we are waiting on for this event. Does not include yourself
| [in] | eventId | A user-defined identifier |
| bool RakNet::ReadyEvent::HasEvent | ( | int | eventId | ) |
Returns if this is a known event. Events may be known even if we never ourselves referenced them with SetEvent, because other systems created them via ID_READY_EVENT_SET.
| [in] | eventId | A user-defined identifier |
| bool RakNet::ReadyEvent::IsEventCompleted | ( | int | eventId | ) | const |
Returns if the wait list is a subset of the completion list. Call this after all systems you want to wait for have been added with AddToWaitList If you are waiting for a specific number of systems (such as players later connecting), also check GetRemoteWaitListSize(eventId) to be equal to 1 less than the total number of participants.
| [in] | eventId | A user-defined identifier |
| bool RakNet::ReadyEvent::IsEventCompletedByIndex | ( | unsigned | eventIndex | ) | const [protected] |
| bool RakNet::ReadyEvent::IsEventCompletionProcessing | ( | int | eventId | ) | const |
Returns if the event is about to be ready and we are negotiating the final packets. This will usually only be true for a very short time, after which IsEventCompleted should return true. While this is true you cannot add to the wait list, or SetEvent() isReady to false anymore.
| [in] | eventId | A user-defined identifier |
| bool RakNet::ReadyEvent::IsEventSet | ( | int | eventId | ) |
Returns what was passed to SetEvent()
| bool RakNet::ReadyEvent::IsInWaitList | ( | int | eventId, |
| SystemAddress | address | ||
| ) |
Returns if a particular system is waiting on a particular event.
| [in] | eventId | A user-defined identifier |
| [in] | The | address of the system we are checking up on |
| virtual void RakNet::ReadyEvent::OnClosedConnection | ( | const SystemAddress & | systemAddress, |
| RakNetGUID | rakNetGUID, | ||
| PI2_LostConnectionReason | lostConnectionReason | ||
| ) | [protected, virtual] |
Called when a connection is dropped because the user called RakPeer::CloseConnection() for a particular system
| [in] | systemAddress | The system whose connection was closed |
| [in] | rakNetGuid | The guid of the specified system |
| [in] | lostConnectionReason | How the connection was closed: manually, connection lost, or notification of disconnection |
Reimplemented from RakNet::PluginInterface2.
| virtual void RakNet::ReadyEvent::OnRakPeerShutdown | ( | void | ) | [protected, virtual] |
Reimplemented from RakNet::PluginInterface2.
| void RakNet::ReadyEvent::OnReadyEventForceAllSet | ( | Packet * | packet | ) | [protected] |
| void RakNet::ReadyEvent::OnReadyEventPacketUpdate | ( | Packet * | packet | ) | [protected] |
| void RakNet::ReadyEvent::OnReadyEventQuery | ( | Packet * | packet | ) | [protected] |
| virtual PluginReceiveResult RakNet::ReadyEvent::OnReceive | ( | Packet * | packet | ) | [protected, virtual] |
OnReceive is called for every packet.
| [in] | packet | the packet that is being returned to the user |
Reimplemented from RakNet::PluginInterface2.
| void RakNet::ReadyEvent::PushCompletionPacket | ( | unsigned | eventId | ) | [protected] |
| static int RakNet::ReadyEvent::ReadyEventNodeComp | ( | const int & | key, |
| ReadyEvent::ReadyEventNode *const & | data | ||
| ) | [static] |
| static int RakNet::ReadyEvent::RemoteSystemCompBySystemAddress | ( | const SystemAddress & | key, |
| const RemoteSystem & | data | ||
| ) | [static] |
| void RakNet::ReadyEvent::RemoveFromAllLists | ( | SystemAddress | address | ) | [protected] |
| bool RakNet::ReadyEvent::RemoveFromWaitList | ( | int | eventId, |
| SystemAddress | address | ||
| ) |
Removes systems from the wait list, which should have been previously added with AddToWaitList
| [in] | address | The system to remove from the wait list. Pass UNASSIGNED_SYSTEM_ADDRESS for all currently connected systems. |
| void RakNet::ReadyEvent::SendReadyStateQuery | ( | unsigned | eventId, |
| SystemAddress | address | ||
| ) | [protected] |
| void RakNet::ReadyEvent::SendReadyUpdate | ( | unsigned | eventIndex, |
| unsigned | systemIndex, | ||
| bool | forceIfNotDefault | ||
| ) | [protected] |
Sets or updates the initial ready state for our local system. If eventId is an unknown event the event is created. If eventId was previously used and you want to reuse it, call DeleteEvent first, or else you will keep the same event signals from before Systems previously or later added through AddToWaitList() with the same eventId when isReady=true will get ID_READY_EVENT_SET Systems previously added through AddToWaitList with the same eventId will get ID_READY_EVENT_UNSET For both ID_READY_EVENT_SET and ID_READY_EVENT_UNSET, eventId is encoded in bytes 1 through 1+sizeof(int)
| [in] | eventId | A user-defined identifier to wait on. This can be a sequence counter, an event identifier, or anything else you want. |
| [in] | isReady | True to signal we are ready to proceed with this event, false to unsignal |
| void RakNet::ReadyEvent::SetSendChannel | ( | unsigned char | newChannel | ) |
This channel will be used for all RakPeer::Send calls
| [in] | newChannel | The channel to use for internal RakPeer::Send calls from this system. Defaults to 0. |
| void RakNet::ReadyEvent::UpdateReadyStatus | ( | unsigned | eventIndex | ) | [protected] |
unsigned char RakNet::ReadyEvent::channel [protected] |
Definition at line 227 of file ReadyEvent.h.
DataStructures::OrderedList<int, ReadyEventNode*, ReadyEvent::ReadyEventNodeComp> RakNet::ReadyEvent::readyEventNodeList [protected] |
Definition at line 226 of file ReadyEvent.h.
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.