Introducing the events of rooms

We discussed three types of rooms when configuring the server in the previous section. The regular room, game room, and limbo room come with different purposes. Each type of rooms has its own set of available events. We will go through some common room events and compare the availability of the events in the three types of rooms.

Event name

Description

onUserEnterRoom

This is a notification that a user has joined the room. This is useful to draw a new user's information and his graphics on the Flash virtual world when receiving this notification message.

onUserLeaveRoom

This is a notification telling that a user has left the room. Similar to the onUserEnterRoom, we often clean up that user's information when receiving this notification.

onSpectatorSwitched

This event was fired when a spectator switched to a player in the game room.

onRoomAdded

The notification message comes when any room is added to the zone. It is useful when a player stays in the lobby waiting for a new game room creation.

onRoomDeleted

Similar to the onRoomAdded event, this is an event that a room has just been destroyed.

onPublicMessage

When a public message is sent from a user, everyone within the room will receive this event notification.

onPrivateMessage

This is an event when receiving a private message from other users.

Comparing the available events of each room type

The events are broadcasted to the users depending on which room type they are in. It is important to know which events are available while designing the virtual world.

 

Regular room

Game room

Limbo room

onUserEnterRoom

Yes

Yes

No

onUserLeaveRoom

Yes

Yes

No

onSpectatorSwitched

No

Yes

No

onRoomAdded

Yes

No

Yes

onRoomDeleted

Yes

No

Yes

onPublicMessage

Yes

Yes

No

onPrivateMessage

Yes

Yes

Yes

From the preceding table we can see that game room will not receive onRoomAdded/onRoomDeleted messages because while playing a game we are usually not interested whether a new room is created or deleted.

The limbo room as described before only receives onRoomAdded/onRoomDeleted and onPrivateMessage events. Other events that may cause large traffic are all disabled in the limbo room to ensure that the limbo room can handle thousands of concurrent user connections without increasing the traffic bandwidth.

We discussed some basic events in this section. A full list of events and details can be found here:

http://smartfoxserver.com/docs/docPages/as3/html/it_gotoandplay_smartfoxserver_SFSEvent.html

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.40.177