show where a user seeked from

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": { case "SetTime": {
const messageContent = document.createElement("span"); 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( 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); printChatMessage("set-time", event.user, event.colour, messageContent);

View File

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

View File

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

View File

@ -84,11 +84,18 @@ pub async fn ws_subscribe(session_uuid: Uuid, nickname: String, colour: String,
None => continue, None => continue,
}; };
handle_watch_event_data( let session = &mut get_session(session_uuid).unwrap();
session_uuid,
&mut get_session(session_uuid).unwrap(), // server side event modification where neccessary
event.clone(), 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( ws_publish(
session_uuid, session_uuid,

View File

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