mirror of https://notabug.org/acetone/ircabot.git
audio notification
parent
13a9939030
commit
2cfa9d51ed
1
html.qrc
1
html.qrc
|
@ -8,5 +8,6 @@
|
|||
<file>html/svg/message.svg</file>
|
||||
<file>html/realtimechat.js</file>
|
||||
<file>html/svg/airplane.svg</file>
|
||||
<file>html/newmessage.mp3</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
Binary file not shown.
|
@ -4,14 +4,15 @@ let objCurrentServerStatus = document.getElementById("serverStatus");
|
|||
let objOnlineCounter = document.getElementById("online");
|
||||
let objOnlineList = document.getElementById("onlineList");
|
||||
|
||||
const HTML_SERVER_ONLINE_MARKER = "✅";
|
||||
const HTML_SERVER_OFFLINE_MARKER = "❌";
|
||||
|
||||
let ajaxUrl = document.getElementById("ajaxPath").innerText;
|
||||
let lastMessageId = document.getElementById("LMId").innerText;
|
||||
let reqIsFailed = false;
|
||||
let firstLoadingWithDisconnectedServer = false;
|
||||
|
||||
const ajaxUrl = document.getElementById("ajaxPath").innerText;
|
||||
const audio = new Audio('/newmessage.mp3');
|
||||
const HTML_SERVER_ONLINE_MARKER = "✅";
|
||||
const HTML_SERVER_OFFLINE_MARKER = "❌";
|
||||
|
||||
function appendMessage(nick /* if == "***", then system message */, message)
|
||||
{
|
||||
let messageObject = document.createElement("div");
|
||||
|
@ -26,7 +27,10 @@ function appendMessage(nick /* if == "***", then system message */, message)
|
|||
nicknameContainer.innerText = "IRCaBot";
|
||||
} else {
|
||||
nicknameContainer.innerText = nick;
|
||||
nicknameContainer.setAttribute("style", "color: #1b4af5")
|
||||
nicknameContainer.setAttribute("style", "color: #1b4af5");
|
||||
if (document.hidden) {
|
||||
audio.play();
|
||||
}
|
||||
}
|
||||
|
||||
let textContainer = document.createElement("div");
|
||||
|
|
|
@ -197,6 +197,25 @@ void HttpServer::reader()
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (urlPath == "/newmessage.mp3") {
|
||||
QString eTag = global::getValue(request, "If-None-Match", global::eHttpHeader);
|
||||
if (eTag == HTTP_ACTUAL_ETAG) {
|
||||
if (socket->isOpen()) socket->write(HEADER_304.toUtf8());
|
||||
}
|
||||
else {
|
||||
QFile mp3("://html/newmessage.mp3");
|
||||
if (mp3.open(QIODevice::ReadOnly)) {
|
||||
QByteArray file = mp3.readAll();
|
||||
mp3.close();
|
||||
QString header = HEADER_MP3;
|
||||
replaceTag(header, "SIZE", QString::number(file.size()));
|
||||
if (socket->isOpen()) {
|
||||
socket->write(header.toUtf8());
|
||||
if (not isHeadRequest) socket->write(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (urlPath == "/style.css") {
|
||||
QString eTag = global::getValue(request, "If-None-Match", global::eHttpHeader);
|
||||
if (eTag == HTTP_ACTUAL_ETAG) {
|
||||
|
|
|
@ -125,6 +125,12 @@ Content-Length: {{SIZE}}\r\n\r\n";
|
|||
const QString HEADER_JSON = "\
|
||||
HTTP/1.1 200 OK\r\n\
|
||||
Content-Type: application/json; charset=utf-8\r\n\
|
||||
Content-Length: {{SIZE}}\r\n\r\n";
|
||||
|
||||
const QString HEADER_MP3 = "\
|
||||
HTTP/1.1 200 OK\r\n\
|
||||
Content-Type: audio/mpeg;\r\n\
|
||||
ETag: \""+HTTP_ACTUAL_ETAG+"\"\r\n\
|
||||
Content-Length: {{SIZE}}\r\n\r\n";
|
||||
|
||||
const QString HEADER_304 = "HTTP/1.1 304 Not Modified\r\nContent-Length: 0\r\n\r\n";
|
||||
|
|
Loading…
Reference in New Issue