Skip to main content

AMS Dynamic Action

Overview (Join Room)

Overview (Send Message)

Settings

Type

Join Room

AMS will use this to connect to the AMS Server and join rooms that you specify. You can specify one or more room names to join and listen for events in that room.

Send Message

AMS sends a message to the server via the socket.

Room Name(s) (Join Room and Send Message)

When joining a room, you can specify one or more room names to join and listen for events in that room. Separate them by a comma. e.g. room1,room2,room3

When sending a message, you can specify one or more room names to send messages to. Separate them by a comma. e.g. room1,room2,room3. You don't have to join a certain room to send a message to that room.

Username (Join Room, optional)

You can optionally specify a username. This can be handy if you want to provide the end user with the username. (e.g., the username in a chat application)

Broadcast (Send Message)

Broadcasting a message will send the message to all users except the user that sent the message. This is useful for sending messages to all users in a room.

Data Type

Data Type is the type of data you want to send to the server; depending on what Data Type you choose, the JSON sent to the server will look different. The following data types are supported:

  • SQL Query
  • PL/SQL Function Body Returning JSON
  • JSON

Data Source: SQL Query

When you choose SQL Query as Data Type, you can specify a SQL Query that will be executed, and the result will be sent to the server. The result will always be sent as a JSON Array, even when the query returns one result.

Example:

[
{
"deptno": 10,
"dname": "ACCOUNTING",
"loc": "NEW YORK"
}
]

Data Source: PL/SQL Function Body Returning JSON

When you choose PL/SQL Function Body Returning JSON as Data Type, you can specify a PL/SQL Function Body that will be executed, and the result will be sent to the server. The result will be sent as a JSON Object/Array, depending on your query.

Example:

{
"deptno": 10,
"dname": "ACCOUNTING",
"loc": "NEW YORK"
}

Example 2:

[
{
"deptno": 10,
"dname": "ACCOUNTING",
"loc": "NEW YORK"
},
{
"deptno": 20,
"dname": "RESEARCH",
"loc": "DALLAS"
}
]

Data Source: JSON

When you choose JSON as Data Type, you can specify a JSON Object/Array that will be sent to the server.

Example:

{
"deptno": 10,
"dname": "ACCOUNTING",
"loc": "NEW YORK"
}

JS API

When you install the DA plug-in, you can use the following JS Functions to interact with the AMS Server directly.

note

You can only use this API when you have already joined a room using the DA Plug-in. You can then still send messages to rooms you have not joined!

uc.ams.emit(JSON)
uc.ams.broadcast(JSON)

uc.ams.emit(JSON)

Use this function to send a message to everyone in the room. The message will also be sent to the user who sent the message.

Example:

uc.ams.emit({
// Rooms is required, this is the name of the room(s) that you want to send the message to
"rooms": "AMS-Sample-Room",
"username": "AMS-Sample-User",
"deptno": 10,
"dname": "ACCOUNTING",
"loc": "NEW YORK"
})

uc.ams.broadcast(JSON)

Use this function to send a message to everyone in the room except the user that sent the message.

Example:

uc.ams.broadcast({
"rooms": "AMS-Sample-Room",
"data": [{
"deptno": 10,
"dname": "ACCOUNTING",
"loc": "NEW YORK"
}, {
"deptno": 20,
"dname": "RESEARCH",
"loc": "DALLAS"
}]
})