show where a user seeked from

votekiss
maia arson crimew 2022-02-13 17:58:31 +01:00
parent 852270c63f
commit 951007df2a
5 changed files with 43 additions and 15 deletions

View File

@ -200,10 +200,22 @@ export const logEventToChat = (event) => {
}
case "SetTime": {
const messageContent = document.createElement("span");
messageContent.appendChild(document.createTextNode("set the time to "));
if (event.data.from != undefined) {
messageContent.appendChild(
document.createTextNode("set the time from ")
);
messageContent.appendChild(
document.createTextNode(formatTime(event.data))
document.createTextNode(formatTime(event.data.from))
);
messageContent.appendChild(document.createTextNode(" to "));
} else {
messageContent.appendChild(document.createTextNode("set the time to "));
}
messageContent.appendChild(
document.createTextNode(formatTime(event.data.to))
);
printChatMessage("set-time", event.user, event.colour, messageContent);

View File

@ -137,7 +137,9 @@ const setupOutgoingEvents = (video, socket) => {
socket.send(
JSON.stringify({
op: "SetTime",
data: currentVideoTime(),
data: {
to: currentVideoTime(),
},
})
);
});

View File

@ -3,13 +3,20 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Serialize, Deserialize)]
#[serde(tag = "op", content = "data")]
pub enum WatchEventData {
SetPlaying { playing: bool, time: u64 },
SetTime(u64),
SetPlaying {
playing: bool,
time: u64,
},
SetTime {
#[serde(default, skip_serializing_if = "Option::is_none")]
from: Option<u64>,
to: u64,
},
UserJoin,
UserLeave,
ChatMessage(String),
Ping(String)
Ping(String),
}
#[derive(Clone, Serialize, Deserialize)]

View File

@ -84,11 +84,18 @@ pub async fn ws_subscribe(session_uuid: Uuid, nickname: String, colour: String,
None => continue,
};
handle_watch_event_data(
session_uuid,
&mut get_session(session_uuid).unwrap(),
event.clone(),
);
let session = &mut get_session(session_uuid).unwrap();
// server side event modification where neccessary
let event: WatchEventData = match event {
WatchEventData::SetTime { from: _, to } => WatchEventData::SetTime {
from: Some(session.get_time_ms()),
to: to,
},
_ => event,
};
handle_watch_event_data(session_uuid, session, event.clone());
ws_publish(
session_uuid,

View File

@ -85,8 +85,8 @@ pub fn handle_watch_event_data(
watch_session.set_playing(playing, time);
}
WatchEventData::SetTime(time) => {
watch_session.set_time_ms(time);
WatchEventData::SetTime { from: _, to } => {
watch_session.set_time_ms(to);
}
_ => {}