Menu

Agent

Agent is an application logic entity managed by AgentManager. It uses basic service features provided in the EDU SDK. It can also use other agents to access its own features.

Concept of agent

The EDU SDK provides eleven agents, all with their own distinct roles:

  • SDK agents are created when the UI calls AgentManager.createInstance(context).
  • BaseAgent is an abstract class which holds all the basic details required by an agent.
  • All supported and custom agents are extended from BaseAgent.

BaseAgent uses the following components:

  • ServiceFetcher – When agents are created and added, AgentManager provides ServiceFetcher to access basic service features.
  • AgentMediatorCallback – This enables to interact with other agents for their features.

AgentManager creates and loads the agents. After successfully creating the agents, the AgentManager can initialize service features. Agent Map enables the AgentMediator to manage all the agents and dispatch the network messages to the respective agent.

All the agents are inherited from the BaseAgent. The BaseAgent has callback methods to notify subclasses and to inform the changes in the user status.

BaseAgent API methods:

API Description
onInitialized() Called when agent is added to AgentManager successfully and is ready to start. SDK users can add their application initializing code here.
onStarted() Called when session is started. Agent can receive network message(event/data) from now.
onStopped() Called when session is stopped. Agent stops receiving the network message from now. SDK users can add their application, delete and clear memory references code here.
onSessionStarted() Called when session is started successfully. Agents start listening to user status changes from now.
onSessionStopped() Called when session is stopped successfully.
onUpdate(ReceivedData receivedData) Called when message is arrived to agent. ReceivedData is a struct.
onUpdate(int cmd, byte[] data, String ipAddr) Called when message is arrived to agent. Receive data has command, payload bytes array and sender IP address.
onDisconnected() Called when device is disconnected from network.
onReconnected() Called when device is reconnected to same network.
sendData() Send data for recipients using network information.

User status change notifier callbacks:>

Callback Description
onUserJoined(User user) New user has joined the session. User object contains the network information of user.
onUserRejoined(User user) User who already joined the session has rejoined because of uncertain events.
onUserLeft(User user) User left from the current session.
onUserReconfigured (User user) User who already joined the session and user's network information is reconfigured due to uncertain events.

You can create your own custom agent by extending the BaseAgent. Once a custom agent is created and added successfully to the AgentManager, the required user status notifications (mentioned in above table) are served to a custom agent automatically by the SDK.

For more details about the custom agent, see Creating custom agent.

AgentManager

The AgentManager is the main class of the EDU SDK. To use the EDU SDK, you must create an instance of this class by following these steps:

  1. Create SamsungEducation instance and call the initialize method.
  2. Access the AgentManager by calling the API method AgentManager.getInstance().

The AgentManager is responsible for the following actions:

  1. Manage the SDK and custom agents which are added to the AgentManager.
  2. Manage the life cycle of services using ServiceMain.
  3. Runs service broker to feed UI and non-agent components.
  4. Dispatch event commands to the respective agent.
  5. Provide API methods to support auto testing of SDK supported agents.
  6. Provide API methods to add a custom agent, and also to get the SDK and its supported agent details.
  7. Handle network callbacks requests for registration and unregistration.

AgentManager has three states:

  • READY
  • STARTED
  • RUNNING

The AgentManager acts as a gateway to add/remove your custom agents (extended from BaseAgent) which receives the same role like other predefined agents provided by the SDK.