Flip LiveSession::session_id private, add getter

This commit is contained in:
Lucien Greathouse
2019-02-27 14:54:05 -08:00
parent 16f8975b18
commit eb97e925e6
2 changed files with 9 additions and 5 deletions

View File

@@ -34,7 +34,7 @@ impl_from!(LiveSessionError {
/// Contains all of the state for a Rojo live-sync session. /// Contains all of the state for a Rojo live-sync session.
pub struct LiveSession { pub struct LiveSession {
project: Arc<Project>, project: Arc<Project>,
pub session_id: SessionId, session_id: SessionId,
pub message_queue: Arc<MessageQueue<InstanceChanges>>, pub message_queue: Arc<MessageQueue<InstanceChanges>>,
pub rbx_session: Arc<Mutex<RbxSession>>, pub rbx_session: Arc<Mutex<RbxSession>>,
pub imfs: Arc<Mutex<Imfs>>, pub imfs: Arc<Mutex<Imfs>>,
@@ -85,6 +85,10 @@ impl LiveSession {
Ok(()) Ok(())
} }
pub fn session_id(&self) -> SessionId {
self.session_id
}
pub fn serve_place_ids(&self) -> &Option<HashSet<u64>> { pub fn serve_place_ids(&self) -> &Option<HashSet<u64>> {
&self.project.serve_place_ids &self.project.serve_place_ids
} }

View File

@@ -144,7 +144,7 @@ impl ApiService {
response_json(&ServerInfoResponse { response_json(&ServerInfoResponse {
server_version: self.server_version, server_version: self.server_version,
protocol_version: 2, protocol_version: 2,
session_id: self.live_session.session_id, session_id: self.live_session.session_id(),
expected_place_ids: self.live_session.serve_place_ids().clone(), expected_place_ids: self.live_session.serve_place_ids().clone(),
root_instance_id: tree.get_root_id(), root_instance_id: tree.get_root_id(),
}) })
@@ -173,7 +173,7 @@ impl ApiService {
if !new_messages.is_empty() { if !new_messages.is_empty() {
return response_json(&SubscribeResponse { return response_json(&SubscribeResponse {
session_id: self.live_session.session_id, session_id: self.live_session.session_id(),
messages: Cow::Borrowed(&new_messages), messages: Cow::Borrowed(&new_messages),
message_cursor: new_cursor, message_cursor: new_cursor,
}) })
@@ -198,7 +198,7 @@ impl ApiService {
let (new_cursor, new_messages) = message_queue.get_messages_since(cursor); let (new_cursor, new_messages) = message_queue.get_messages_since(cursor);
return response_json(&SubscribeResponse { return response_json(&SubscribeResponse {
session_id: self.live_session.session_id, session_id: self.live_session.session_id(),
messages: Cow::Owned(new_messages), messages: Cow::Owned(new_messages),
message_cursor: new_cursor, message_cursor: new_cursor,
}) })
@@ -255,7 +255,7 @@ impl ApiService {
} }
response_json(&ReadResponse { response_json(&ReadResponse {
session_id: self.live_session.session_id, session_id: self.live_session.session_id(),
message_cursor, message_cursor,
instances, instances,
}) })