Diarkis Room - Handling Room Events On The Server

Capturing Changes In A Room As An Event

Rooms raise an event whenever there is a change to the room. Changes with room properties, change of room members (joining and leaving), and change of room owner will trigger this event.

room.SetOnRoomChange(func(roomID string, memberIDs []string, props                    map[string]interface{}) {
    logger.Debug("There has been a change in the room %s", roomID)
})

Capturing The Event On Room Owner Change

A room has an owner (The client that created the room or automatically elected member of the room). You may capture the event that is raised when the owner changes.

room.SetOnRoomOwnerChange(func(params interface{}) {
      roomData := params.(map[string]string)
      roomID := roomData["string"]
      roomOWnerUID := roomData["ownerID"]
      logger.Debug("The owner of the room %s has changed to %s", roomID, roomOwnerUID)
})

Capturing The Event On Room Property Change

The event is raised when room properties are changed.

room.SetOnRoomPropertyUpdate(func(params interface{}) {
    roomData := params.(map[string]interface{})
    roomID := roomData["roomID"].(string)
    properties := roomData.["properties"].(interface{}).(map[string]interface{})
    logger.Debug("Room %s has detect change in its properties %v", roomID, properties)
})

Capturing The Event On Room Destruction

The event is raised when a room has been deleted from the server.

room.SetOnRoomDiscard(func(roomID string) {
        logger.Debug("Room %s has been discarded", roomID)
})