我正在开发一个基于Web的应用程序,其目标是在同一WiFi连接上的设备之间共享文件。我是一名JavaScript开发人员,但我从未使用过连接技术。有没有办法我可以使用javascript / jquery或任何其他API做到这一点?
我只知道Network Information API,它返回连接类型的信息以及其他一些信息。到目前为止,我只能检查连接类型和速度。
var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
if (connection) {
var connection_type=connection.type;
var effectivetype=connection.effectiveType;
var downSpeed = connection.downlink;
console.log('download speed'+downSpeed +'effectivetype:'+effectivetype'+
Connection type:'+connection_type);
}
var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
if (connection) {
var connection_type=connection.type;
if (connection_type=='wifi') {
//the device is connected to a wifi
var wifi_name = 'mywifi';
if (wifi_name == 'mywifi') {
//device is connected to my wifi
var create_connection = create a connection();
if (create_connection) {
//a connection is created between two devices
send_file();
//send a file
}
}
}
}
答案 0 :(得分:0)
我偶然发现了该网页,其中提供了您所需的东西,请访问:www.bridgefy.me