RecvSharedEvent ( )

Parameters

None.

Description

Takes the next Shared World event; returns True if there was one.

Events tell you what happened in the session: players joining and leaving, entities appearing and going, refused requests, a lost connection, a change of host. After it returns True, SharedEventType, SharedEventPlayer, SharedEventEntity and SharedEventData describe the event. Read every event each frame with a loop:

While RecvSharedEvent()
    Select SharedEventType()
    Case SHARED_EVENT_PLAYER_JOINED
        status$=SharedPlayerName(SharedEventPlayer())+" joined"
    Case SHARED_EVENT_SESSION_LOST
        status$="Connection lost: "+SharedEventData()
    End Select
Wend

Events report changes, not the starting state: when your session becomes ready, read the players and entities that are already there with SharedPlayerCount and SharedPlayerEntity. Events wait in a queue of at most 1024, like messages, and an overflowing queue ends the session, so read both queues every frame.

For the full story - services, hosting, sharing and host migration - see the Shared World guide and its complete Shared_World_Playground.bb sample.


See also: SharedEventType, SharedEventPlayer, SharedEventEntity, SharedEventData, RecvSharedMsg, Constants.

Index