show where a user seeked from
This commit is contained in:
parent
852270c63f
commit
951007df2a
5 changed files with 43 additions and 15 deletions
|
@ -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(
|
||||||
|
document.createTextNode(formatTime(event.data.from))
|
||||||
|
);
|
||||||
|
|
||||||
|
messageContent.appendChild(document.createTextNode(" to "));
|
||||||
|
} else {
|
||||||
|
messageContent.appendChild(document.createTextNode("set the time to "));
|
||||||
|
}
|
||||||
|
|
||||||
messageContent.appendChild(
|
messageContent.appendChild(
|
||||||
document.createTextNode(formatTime(event.data))
|
document.createTextNode(formatTime(event.data.to))
|
||||||
);
|
);
|
||||||
|
|
||||||
printChatMessage("set-time", event.user, event.colour, messageContent);
|
printChatMessage("set-time", event.user, event.colour, messageContent);
|
||||||
|
|
|
@ -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(),
|
||||||
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -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)]
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
Loading…
Reference in a new issue