[mirotalksfu] - add geolocation
هذا الالتزام موجود في:
@@ -49,6 +49,7 @@ const _PEER = {
|
||||
lowerHand: '',
|
||||
acceptPeer: '<i class="fas fa-check"></i>',
|
||||
ejectPeer: '<i class="fas fa-times"></i>',
|
||||
geoLocation: '<i class="fas fa-location-dot"></i>',
|
||||
sendFile: '<i class="fas fa-upload"></i>',
|
||||
sendMsg: '<i class="fas fa-paper-plane"></i>',
|
||||
sendVideo: '<i class="fab fa-youtube"></i>',
|
||||
@@ -2134,6 +2135,7 @@ function handleRoomEmojiPicker() {
|
||||
type: 'roomEmoji',
|
||||
peer_name: peer_name,
|
||||
emoji: data.native,
|
||||
broadcast: true,
|
||||
};
|
||||
if (rc.thereAreParticipants()) {
|
||||
rc.emitCmd(cmd);
|
||||
@@ -3205,6 +3207,7 @@ function getParticipantsList(peers) {
|
||||
const peer_screen = peer_info.peer_screen ? _PEER.screenOn : _PEER.screenOff;
|
||||
const peer_hand = peer_info.peer_hand ? _PEER.raiseHand : _PEER.lowerHand;
|
||||
const peer_eject = _PEER.ejectPeer;
|
||||
const peer_geoLocation = _PEER.geoLocation;
|
||||
const peer_sendFile = _PEER.sendFile;
|
||||
const peer_id = peer_info.peer_id;
|
||||
const avatarImg = getParticipantAvatar(peer_name);
|
||||
@@ -3243,6 +3246,7 @@ function getParticipantsList(peers) {
|
||||
<ul class="dropdown-menu text-start" aria-labelledby="${peer_id}-chatDropDownMenu">
|
||||
<li><button class="btn-sm ml5" id='${peer_id}___shareFile' onclick="rc.selectFileToShare('${peer_id}', false)">${peer_sendFile} Share file</button></li>
|
||||
<li><button class="btn-sm ml5" id="${peer_id}___sendVideoTo" onclick="rc.shareVideo('${peer_id}');">${_PEER.sendVideo} Share audio/video</button></li>
|
||||
<li><button class="btn-sm ml5" id='${peer_id}___geoLocation' onclick="rc.askPeerGeoLocation(this.id)">${peer_geoLocation} Get geolocation</button></li>
|
||||
<li><button class="btn-sm ml5" id='${peer_id}___pEject' onclick="rc.peerAction('me',this.id,'eject')">${peer_eject} Eject participant</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -91,6 +91,7 @@ const image = {
|
||||
all: '../images/all.png',
|
||||
forbidden: '../images/forbidden.png',
|
||||
broadcasting: '../images/broadcasting.png',
|
||||
geolocation: '../images/geolocation.png',
|
||||
};
|
||||
|
||||
const mediaType = {
|
||||
@@ -3124,6 +3125,7 @@ class RoomClient {
|
||||
type: 'privacy',
|
||||
peer_id: this.peer_id,
|
||||
active: isVideoPrivacyActive,
|
||||
broadcast: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -5437,6 +5439,16 @@ class RoomClient {
|
||||
case 'transcript':
|
||||
this.transcription.handleTranscript(cmd);
|
||||
break;
|
||||
case 'geoLocation':
|
||||
this.confirmPeerGeoLocation(cmd);
|
||||
break;
|
||||
case 'geoLocationOK':
|
||||
this.handleGeoPeerLocation(cmd);
|
||||
break;
|
||||
case 'geoLocationKO':
|
||||
this.sound('alert');
|
||||
this.userLog('warning', cmd.data, 'top-end', 5000);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
//...
|
||||
@@ -5470,6 +5482,7 @@ class RoomClient {
|
||||
const peer_id = words[0];
|
||||
|
||||
if (emit) {
|
||||
// send...
|
||||
const data = {
|
||||
from_peer_name: this.peer_name,
|
||||
from_peer_id: this.peer_id,
|
||||
@@ -5566,6 +5579,7 @@ class RoomClient {
|
||||
}
|
||||
this.confirmPeerAction(data.action, data);
|
||||
} else {
|
||||
// receive...
|
||||
const peerActionAllowed = peer_id === this.peer_id || broadcast;
|
||||
switch (action) {
|
||||
case 'eject':
|
||||
@@ -6197,4 +6211,130 @@ class RoomClient {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ####################################################
|
||||
// HANDLE PEER GEOLOCATION
|
||||
// ####################################################
|
||||
|
||||
askPeerGeoLocation(id) {
|
||||
const words = id.split('___');
|
||||
const peer_id = words[0];
|
||||
const cmd = {
|
||||
type: 'geoLocation',
|
||||
from_peer_name: this.peer_name,
|
||||
from_peer_id: this.peer_id,
|
||||
peer_id: peer_id,
|
||||
broadcast: false,
|
||||
};
|
||||
this.emitCmd(cmd);
|
||||
}
|
||||
|
||||
sendPeerGeoLocation(peer_id, type, data) {
|
||||
const cmd = {
|
||||
type: type,
|
||||
from_peer_name: this.peer_name,
|
||||
from_peer_id: this.peer_id,
|
||||
peer_id: peer_id,
|
||||
data: data,
|
||||
broadcast: false,
|
||||
};
|
||||
this.emitCmd(cmd);
|
||||
}
|
||||
|
||||
confirmPeerGeoLocation(cmd) {
|
||||
this.sound('notify');
|
||||
Swal.fire({
|
||||
allowOutsideClick: false,
|
||||
allowEscapeKey: false,
|
||||
background: swalBackground,
|
||||
imageUrl: image.geolocation,
|
||||
position: 'center',
|
||||
title: 'Geo Location',
|
||||
html: `Would you like to share your location to ${cmd.from_peer_name}?`,
|
||||
showDenyButton: true,
|
||||
confirmButtonText: `Yes`,
|
||||
denyButtonText: `No`,
|
||||
showClass: { popup: 'animate__animated animate__fadeInDown' },
|
||||
hideClass: { popup: 'animate__animated animate__fadeOutUp' },
|
||||
}).then((result) => {
|
||||
result.isConfirmed ? this.getPeerGeoLocation(cmd.from_peer_id) : this.denyPeerGeoLocation(cmd.from_peer_id);
|
||||
});
|
||||
}
|
||||
|
||||
getPeerGeoLocation(peer_id) {
|
||||
if ('geolocation' in navigator) {
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
function (position) {
|
||||
const geoLocation = {
|
||||
latitude: position.coords.latitude,
|
||||
longitude: position.coords.longitude,
|
||||
};
|
||||
console.log('GeoLocation --->', geoLocation);
|
||||
|
||||
rc.sendPeerGeoLocation(peer_id, 'geoLocationOK', geoLocation);
|
||||
// openURL(`https://www.openstreetmap.org/?mlat=${geoLocation.latitude}&mlon=${geoLocation.longitude}`, true);
|
||||
// openURL(`http://maps.apple.com/?ll=${geoLocation.latitude},${geoLocation.longitude}`, true);
|
||||
// openURL(`https://www.google.com/maps/search/?api=1&query=${geoLocation.latitude},${geoLocation.longitude}`, true);
|
||||
},
|
||||
function (error) {
|
||||
let geoError = error;
|
||||
switch (error.code) {
|
||||
case error.PERMISSION_DENIED:
|
||||
geoError = 'User denied the request for Geolocation';
|
||||
break;
|
||||
case error.POSITION_UNAVAILABLE:
|
||||
geoError = 'Location information is unavailable';
|
||||
break;
|
||||
case error.TIMEOUT:
|
||||
geoError = 'The request to get user location timed out';
|
||||
break;
|
||||
case error.UNKNOWN_ERROR:
|
||||
geoError = 'An unknown error occurred';
|
||||
break;
|
||||
}
|
||||
rc.sendPeerGeoLocation(peer_id, 'geoLocationKO', `${rc.peer_name}: geoError`);
|
||||
rc.userLog('warning', geoError, 'top-end', 5000);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
rc.sendPeerGeoLocation(
|
||||
peer_id,
|
||||
'geoLocationKO',
|
||||
`${rc.peer_name}: Geolocation is not supported by this browser`,
|
||||
);
|
||||
rc.userLog('warning', 'Geolocation is not supported by this browser', 'top-end', 5000);
|
||||
}
|
||||
}
|
||||
|
||||
denyPeerGeoLocation(peer_id) {
|
||||
rc.sendPeerGeoLocation(peer_id, 'geoLocationKO', `${rc.peer_name}: Has declined permission for geolocation`);
|
||||
}
|
||||
|
||||
handleGeoPeerLocation(cmd) {
|
||||
const geoLocation = cmd.data;
|
||||
this.sound('notify');
|
||||
Swal.fire({
|
||||
allowOutsideClick: false,
|
||||
allowEscapeKey: false,
|
||||
background: swalBackground,
|
||||
imageUrl: image.geolocation,
|
||||
position: 'center',
|
||||
title: 'Geo Location',
|
||||
html: `Would you like to open ${cmd.from_peer_name} geolocation?`,
|
||||
showDenyButton: true,
|
||||
confirmButtonText: `Yes`,
|
||||
denyButtonText: `No`,
|
||||
showClass: { popup: 'animate__animated animate__fadeInDown' },
|
||||
hideClass: { popup: 'animate__animated animate__fadeOutUp' },
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
// openURL(`https://www.openstreetmap.org/?mlat=${geoLocation.latitude}&mlon=${geoLocation.longitude}`, true);
|
||||
// openURL(`http://maps.apple.com/?ll=${geoLocation.latitude},${geoLocation.longitude}`, true);
|
||||
openURL(
|
||||
`https://www.google.com/maps/search/?api=1&query=${geoLocation.latitude},${geoLocation.longitude}`,
|
||||
true,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
} // End
|
||||
|
||||
@@ -118,6 +118,7 @@ class Transcription {
|
||||
peer_name: peer_name,
|
||||
text_data: transcript,
|
||||
time_stamp: new Date(),
|
||||
broadcast: true,
|
||||
};
|
||||
if (transcript) {
|
||||
this.sendTranscript(transcriptionData);
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم