mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-23 22:25:26 +00:00
Turn messages into stub SubscribeMessage struct
This commit is contained in:
@@ -8,6 +8,7 @@ use crate::{
|
|||||||
message_queue::MessageQueue,
|
message_queue::MessageQueue,
|
||||||
project::Project,
|
project::Project,
|
||||||
session_id::SessionId,
|
session_id::SessionId,
|
||||||
|
snapshot::AppliedPatchSet,
|
||||||
snapshot::RojoTree,
|
snapshot::RojoTree,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ pub struct ServeSession<F> {
|
|||||||
root_project: Option<Project>,
|
root_project: Option<Project>,
|
||||||
session_id: SessionId,
|
session_id: SessionId,
|
||||||
tree: Mutex<RojoTree>,
|
tree: Mutex<RojoTree>,
|
||||||
message_queue: MessageQueue<()>, // TODO: Real message type
|
message_queue: MessageQueue<AppliedPatchSet>,
|
||||||
imfs: Imfs<F>,
|
imfs: Imfs<F>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +43,7 @@ impl<F: ImfsFetcher> ServeSession<F> {
|
|||||||
&self.imfs
|
&self.imfs
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn message_queue(&self) -> &MessageQueue<()> {
|
pub fn message_queue(&self) -> &MessageQueue<AppliedPatchSet> {
|
||||||
&self.message_queue
|
&self.message_queue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ pub struct PatchUpdate {
|
|||||||
///
|
///
|
||||||
// TODO: Introduce machinery to detect conflicts, like keeping previous +
|
// TODO: Introduce machinery to detect conflicts, like keeping previous +
|
||||||
// current values in all fields.
|
// current values in all fields.
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub struct AppliedPatchSet {
|
pub struct AppliedPatchSet {
|
||||||
pub removed: Vec<RbxId>,
|
pub removed: Vec<RbxId>,
|
||||||
pub added: Vec<AppliedPatchAdd>,
|
pub added: Vec<AppliedPatchAdd>,
|
||||||
@@ -76,10 +77,12 @@ impl AppliedPatchSet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub struct AppliedPatchAdd {
|
pub struct AppliedPatchAdd {
|
||||||
pub instance_id: RbxId,
|
pub instance_id: RbxId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub struct AppliedPatchUpdate {
|
pub struct AppliedPatchUpdate {
|
||||||
pub id: RbxId,
|
pub id: RbxId,
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ use std::collections::HashMap;
|
|||||||
use rbx_dom_weak::{RbxId, RbxInstanceProperties, RbxValue};
|
use rbx_dom_weak::{RbxId, RbxInstanceProperties, RbxValue};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
patch::{PatchSet, PatchUpdate},
|
patch::{AppliedPatchSet, PatchSet, PatchUpdate},
|
||||||
InstancePropertiesWithMeta, InstanceSnapshot, RojoTree,
|
InstancePropertiesWithMeta, InstanceSnapshot, RojoTree,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn apply_patch_set(tree: &mut RojoTree, patch_set: PatchSet) {
|
pub fn apply_patch_set(tree: &mut RojoTree, patch_set: PatchSet) -> AppliedPatchSet {
|
||||||
let mut context = PatchApplyContext::default();
|
let mut context = PatchApplyContext::default();
|
||||||
|
|
||||||
for removed_id in patch_set.removed_instances {
|
for removed_id in patch_set.removed_instances {
|
||||||
@@ -25,6 +25,9 @@ pub fn apply_patch_set(tree: &mut RojoTree, patch_set: PatchSet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
apply_deferred_properties(context, tree);
|
apply_deferred_properties(context, tree);
|
||||||
|
|
||||||
|
// TODO: Actually calculate patch set
|
||||||
|
AppliedPatchSet::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ use crate::{
|
|||||||
serve_session::ServeSession,
|
serve_session::ServeSession,
|
||||||
web::{
|
web::{
|
||||||
interface::{
|
interface::{
|
||||||
ErrorResponse, Instance, ReadResponse, ServerInfoResponse, SubscribeResponse,
|
ErrorResponse, Instance, ReadResponse, ServerInfoResponse, SubscribeMessage,
|
||||||
PROTOCOL_VERSION, SERVER_VERSION,
|
SubscribeResponse, PROTOCOL_VERSION, SERVER_VERSION,
|
||||||
},
|
},
|
||||||
util::{json, json_ok},
|
util::{json, json_ok},
|
||||||
},
|
},
|
||||||
@@ -90,11 +90,19 @@ impl<F: ImfsFetcher> ApiService<F> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Box::new(receiver.then(move |result| match result {
|
Box::new(receiver.then(move |result| match result {
|
||||||
Ok((message_cursor, messages)) => json_ok(SubscribeResponse {
|
Ok((message_cursor, messages)) => {
|
||||||
session_id,
|
// TODO: Transform applied patch sets into subscribe responses
|
||||||
message_cursor,
|
let api_messages = messages
|
||||||
messages,
|
.into_iter()
|
||||||
}),
|
.map(|_message| SubscribeMessage)
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
json_ok(SubscribeResponse {
|
||||||
|
session_id,
|
||||||
|
message_cursor,
|
||||||
|
messages: api_messages,
|
||||||
|
})
|
||||||
|
}
|
||||||
Err(_) => json(
|
Err(_) => json(
|
||||||
ErrorResponse::internal_error("Message queue disconnected sender"),
|
ErrorResponse::internal_error("Message queue disconnected sender"),
|
||||||
StatusCode::INTERNAL_SERVER_ERROR,
|
StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ pub(crate) const SERVER_VERSION: &str = env!("CARGO_PKG_VERSION");
|
|||||||
pub const PROTOCOL_VERSION: u64 = 3;
|
pub const PROTOCOL_VERSION: u64 = 3;
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
pub type SubscribeMessage = ();
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct SubscribeMessage;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
|
|||||||
Reference in New Issue
Block a user