Skip to content

michaelcplusplus/v8test-samples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

v8test-samples

Table of contents

  1. Introduction
  2. BASI API
  3. MQTT API
  4. FCM API
  5. HTTP API
  6. Examples
    6.1 Input form
    6.2 FCM
  7. Show and tell

Introduction

Sample files for Android app Exec JS V8 see Google playstore https://play.google.com/store/apps/details?id=de.mlauer.v8test
The app has full ECMAScript 2016 (ECMA-262) support.

Alt text

Basic API

  • console.log()
  • console.error()
  • console.warn()
  • _read()
  • _write()
  • _inputForm()

console.log(data)
Prints to result view
Text color: blue

console.error(data)
Prints to result view
Text color: red

_read(filename, [convert])
Read filename and return content as string

  • filename filename, String
  • convert optional: convert from iso8859 to utf-8 , Number 0(default) or 1

_write(filename, content)
Write content to file

_inputForm(title, default) Open a input dialog.

  • title title of the dialog, String
  • default default value of the input field, String

Example file v8input.js

MQTT API

  • mqtt.connect()
  • mqtt.publish()
  • mqtt.subscribe()
  • mqtt.disconnect()
  • mqtt.onMqttMessage()

mqtt.connect(url, clientId, options)
Connects to the broker specified by the given url and options

  • url broker url, String
    examples:
    tcp://test.mosquitto.org:1883
    ssl://test.mosquitto.org:8883
  • clientId id of the client, String
  • options server options, JSON - String

mqtt.publish(topic, payload, qos, retain)
Publish a message to a topic

  • topic is the topic to publish to, String
  • payload is the message to publish, String
  • qos QoS level, Number
  • retain retain flag, Boolean

mqtt.subscribe(topic, qos)
Subscribe to a topic

  • topic is the topic to publish to, String
  • qos QoS level, Number

mqtt.disconnect()
Disconnect from the broker

mqtt.onMqttMessage(callback)
Callback function fired when message arrives

  • callback - function (topic, payload)

Example file v8mqtt_test.js

FCM API

  • fcm.publish()

fcm.publish(serverKey, message)
Publish a Firebase cloud message

  • serverKey your server keyt, String
  • message message to publisg, JSON - String

Example file v8fcm.js

HTTP API

  • http.request()

http.request(options)
Execute a http/https request

  • options http request options as JSON string, String

Example file v8http_httpbin_get.js

Example file v8http_httpbin_post.js

Example file v8http_httpbin_basicauth.js

Example file v8http_httpbin_bearerauth.js

Example file v8http_httpbin_headers.js

Examples

Input form example

Alt text

FCM example

Alt text

Show and tell

You are welcome to share your code example in the Show and tell GitHub discussion area.

About

Sample javascript files for android app "Exec JS V8"

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published