1.Run in OS service mode (Server mode):
./mq-p2p-client update-config agentId <yourname> or ./mq-p2p-client generate-id
./mq-p2p-client update-config SERVER https://peer-server.demo.mqsolutions.vn
./mq-p2p-client add-protocol <deviceId> <protocol> <local_port>
./mq-p2p-client startup
Example:
./mq-p2p-client ngochip-agent
./mq-p2p-client add-protocol camera01 127.0.0.1:22 8082
./mq-p2p-client startup
2.Run in SDK mode (client mode):
const PeerConnection = require('PeerConnection'); //import PeerConnection from 'mq-p2p-client'
const peer = new PeerConnection({
agentId: "local-peer-id",
peerId: "remote-peer-id",
server: "https://peer-server.demo.mqsolutions.vn"
});
const result = await peer.createConnection();
const stream = peer.dial("127.0.0.1:8082");
3.Livestream with mq-p2p-stream server:
const videoElement = document.getElementById("video");
const PeerMediaStream = require('PeerMediaStream'); //import {PeerMediaStream} from 'mq-p2p-client'
await PeerMediaStream.connect({
peer: peer, //peerConnection được khởi tạo ở bước trên.
streamServer: "127.0.0.1:6002" //địa chỉ stream server theo remote IP. Mặc định là 127.0.0.1:6002, Optional.
videoElement: videoElement, //video element
cameraId: cameraId //ID của camera tại server stream.
});
Contact Ngoc Hip or MQ ICT Solutions for instructions on deploying: signal servers (mq-p2p-server), stream servers (mq-p2p-stream) and agent services (mq-p2p-agent).