Quantcast
Channel: MobileRead Forums
Viewing all articles
Browse latest Browse all 50094

Tutorial How to send/receive custom events

$
0
0
I'm running Kindle OS 5.17.0 on a Kindle Signature 12th Generation and found that the following can be done to send/receive custom lipc events:

To send a custom event:

Quote:

lipc-send-event aaa.bbb.ccc event_name1 -s "somestring"
lipc-send-event aaa.bbb.ccc event_name2 -i #
where:

Quote:

aaa-bbb-ccc is a "source" for the event
aaa is a custom domain (I used "com")
bbb is package name
ccc is an app name
event_name1/event_name2 are event names
somestring is some text that you want to pass along with the event
# is an integer
Example:

Quote:

lipc-send-event com.mypackage.myapp myevent -s "my event data"
To receive and process the event above:

Quote:

lipc-wait-event -m com.mypackage.myapp playing 2>/dev/null | while read event
do
# $event contains all of the event details in the form:
#
# source name data
#
# where:
#
# data will be enclosed in quotes if a string, and not if a numeric value
#
# We cannot use IFS substitution because the data
# may include spaces. Therefore, we just use cut.
source=$(echo "${event}" | cut -d ' ' -f1)
name=$(echo "${event}" | cut -d ' ' -f2)
data=$(echo "${event}" | cut -d ' ' -f3-)
case "${event}" in
"com.mypackage.myapp myevent"*)
echo "source = ${source}, name = ${name}, data = ${data}"
;;
esac

Viewing all articles
Browse latest Browse all 50094

Latest Images

Trending Articles



Latest Images