forked from lavender/watch-party
show where a user seeked from
parent
852270c63f
commit
951007df2a
|
@ -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);
|
||||
|
|
|
@ -137,7 +137,9 @@ const setupOutgoingEvents = (video, socket) => {
|
|||
socket.send(
|
||||
JSON.stringify({
|
||||
op: "SetTime",
|
||||
data: currentVideoTime(),
|
||||
data: {
|
||||
to: currentVideoTime(),
|
||||
},
|
||||
})
|
||||
);
|
||||
});
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
_ => {}
|
||||
|
|
Loading…
Reference in New Issue