mirror of
https://github.com/ianramzy/decentralized-video-chat.git
synced 2024-11-17 07:39:21 +08:00
Merge branch 'fixes' of github.com:questo-ai/decentralized-video-chat into fixes
This commit is contained in:
commit
22f7edba3e
6
public/css/chat.css
vendored
6
public/css/chat.css
vendored
@ -339,6 +339,9 @@ button:hover {
|
||||
justify-content: center;
|
||||
padding: 12px;
|
||||
max-width: 100%;
|
||||
border-style: solid;
|
||||
border-width: 2px;
|
||||
border-color: var(--bloc-color);
|
||||
border-radius: 20px 20px 20px 5px;
|
||||
box-shadow: 6px 6px 12px #030506, -6px -6px 12px #23242a;
|
||||
}
|
||||
@ -347,6 +350,9 @@ button:hover {
|
||||
#chat-zone .message-item.customer .message-bloc {
|
||||
background-color: rgb(47, 48, 52);
|
||||
color: #fff;
|
||||
border-style: solid;
|
||||
border-width: 2px;
|
||||
border-color: var(--bloc-color);
|
||||
border-radius: 20px 20px 5px 20px;
|
||||
box-shadow: 6px 6px 12px #030506, -6px -6px 12px #22232a;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ var dataChannel = new Map();
|
||||
var VideoChat = {
|
||||
videoEnabled: true,
|
||||
audioEnabled: true,
|
||||
borderColor: `hsl(${Math.floor(Math.random() * 360)}, 70%, 80%)`,
|
||||
connected: new Map(),
|
||||
localICECandidates: {},
|
||||
socket: io(),
|
||||
@ -40,7 +41,7 @@ var VideoChat = {
|
||||
peerConnections: new Map(),
|
||||
recognition: undefined,
|
||||
borderColor: undefined,
|
||||
peerColors: {},
|
||||
peerColors: new Map(),
|
||||
|
||||
// Call to getUserMedia (provided by adapter.js for cross browser compatibility)
|
||||
// asking for access to both the video and audio streams. If the request is
|
||||
@ -175,6 +176,8 @@ var VideoChat = {
|
||||
recieveCaptions(cleanedMessage);
|
||||
} else if (dataType === "tog:") {
|
||||
toggleSendCaptions();
|
||||
} else if (dataType === "clr:") {
|
||||
setStreamColor(uuid, cleanedMessage);
|
||||
}
|
||||
};
|
||||
// Called when dataChannel is successfully opened
|
||||
@ -861,15 +864,28 @@ function uuidToColor(uuid) {
|
||||
var hash = 0;
|
||||
for (var i = 0; i < uuid.length; i++) {
|
||||
hash = uuid.charCodeAt(i) + ((hash << 5) - hash);
|
||||
hash &= hash; // Convert to 32bit integer
|
||||
hash = hash & hash;
|
||||
}
|
||||
return `hsl(${hash % 360},100%,40%)`;
|
||||
var hue = Math.abs(hash % 360);
|
||||
console.log(hue);
|
||||
// Ensure color is not similar to other colors
|
||||
var availColors = Array.from({length: 18}, (x,i) => i*20);
|
||||
VideoChat.peerColors.forEach(function(value, key, map) {availColors[Math.floor(value/20)] = null});
|
||||
if (availColors[Math.floor(hue/20)] == null) {
|
||||
for (var i = 0; i < availColors.length; i++) {
|
||||
if (availColors[i] != null) {
|
||||
hue = (hue % 20) + availColors[i];
|
||||
availColors[i] = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return `hsl(${hue},100%,70%)`;
|
||||
}
|
||||
|
||||
// Sets the border color of uuid's stream
|
||||
function setStreamColor(uuid) {
|
||||
const color = uuidToColor(uuid);
|
||||
console.log(color);
|
||||
document.querySelectorAll(`[uuid="${uuid}"]`)[0].style.border = `3px solid ${color}`;
|
||||
VideoChat.peerColors[uuid] = color;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user