简体   繁体   中英

How could i emit events to a cloud server and listen to it from another network via the url of the website of the cloud server

So i'm hoping if there is a way for me to emit events to cloud server by typing it into the text field of html and listen to that event from another network via nodejs

If you create a socket event on a server. You can listen to that event from anywhere using "socket.io-client".

import io from 'socket.io-client'
const socket = io.connect("http://server_url");

 socket.on("event", () => {
        //do something
      });

Check this documentation https://socket.io/docs/v4/ server and client

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM