Go back to example list / Go to the repository of this example on GitHub
The coordinate points will be pinned and drawn lines when the above subscriber receives them if the coordinate is formatted like the following.
plot lat lng name
Or you can erase your pin by the following message.
erase name
"name" is the name of your pin. But the word "all" is the special one to erase all pins.
This is a control panel for testing the EventSource class, which is for the "Server-Sent Event (SSE)." This class is helpful for your web browser to work as an MQTT subscriber, as it enables server-push data transmission within HTTP regulations. And HTTP/2 is necessary to make the class truly practical. HTTP/2 can make HTTP data transmission both upstream and downstream more efficiently with a single connection.
This control panel runs the mosquitto_pub/mosquitto_sub command in a CGI script on the web server by using the EventSource class and the fetch() method. The Mosquitto commands encapsulate/decapsulate MQTT data, instead of the web client, so that this page can work as not only an MQTT subscriber but also an MQTT publisher.
Try to use me by the following steps.
Typically, I recommend Apache or nginx.
The installation instructions are on this page.Then, Copy and save the following text as the file "mosquitto.local.conf" in your favor directory.
Type the following command on your UNIX terminal.
In the "HOST" section, fill in the URL form (Specify "mqtt://localhost:1883/" to use the above MQTT broker, of course, it's OK to use another broker. If you do so, replace "localhost" in the latter explanations with the other host you specified.)
Move to the "RECV" section. And decide on the MQTT topic name for this trial. Next, type the topic name into the "topicname" field in this section and push the "Start" button in the same section.
Write the same topic name as the one in the "RECV" section. Next, decide on the name of your pin and type it into the "myname" field. Finally, push the "Publish my location" button in the same section. Then you can see your pin on the map.
Or you can also publish the same plotting command from the publisher in the "SEND" section on this HTML. See the "Map" section for the command usage.