Changeset View
Changeset View
Standalone View
Standalone View
shared/tunnelbroker_messages/src/messages/session.rs
// Messages sent between tunnelbroker and a device | // Messages sent between tunnelbroker and a device | ||||
use serde::{Deserialize, Serialize}; | use serde::{Deserialize, Serialize}; | ||||
/// The workflow when establishing a tunnelbroker connection: | /// The workflow when estabilishing a tunnelbroker connection: | ||||
/// - Client sends SessionRequest | /// - Client sends ConnectionInitializationMessage | ||||
/// - Tunnelbroker validates access_token with identity service | /// - Tunnelbroker validates access_token with identity service | ||||
/// - Tunnelbroker emits an AMQP message declaring that it has opened a new | /// - Tunnelbroker emits an AMQP message declaring that it has opened a new | ||||
/// connection with a given device, so that the respective tunnelbroker | /// connection with a given device, so that the respective tunnelbroker | ||||
/// instance can close the existing connection. | /// instance can close the existing connection. | ||||
/// - Tunnelbroker returns a session_id representing that the connection was | /// - Tunnelbroker returns a session_id representing that the connection was | ||||
/// accepted | /// accepted | ||||
/// - Tunnelbroker will flush all messages related to device from RabbitMQ. | /// - Tunnelbroker will flush all messages related to device from RabbitMQ. | ||||
/// This must be done first before flushing DynamoDB to prevent duplicated | /// This must be done first before flushing DynamoDB to prevent duplicated | ||||
Show All 12 Lines | |||||
} | } | ||||
/// Message sent by a client to tunnelbroker to initiate a websocket | /// Message sent by a client to tunnelbroker to initiate a websocket | ||||
/// session. Tunnelbroker will then validate the access token with identity | /// session. Tunnelbroker will then validate the access token with identity | ||||
/// service before continuing with the request. | /// service before continuing with the request. | ||||
#[derive(Serialize, Deserialize)] | #[derive(Serialize, Deserialize)] | ||||
#[serde(tag = "type", rename_all = "camelCase")] | #[serde(tag = "type", rename_all = "camelCase")] | ||||
pub struct ConnectionInitializationMessage { | pub struct ConnectionInitializationMessage { | ||||
pub user_id: String, | |||||
pub device_id: String, | pub device_id: String, | ||||
pub access_token: String, | pub access_token: String, | ||||
pub user_id: String, | |||||
pub notify_token: Option<String>, | pub notify_token: Option<String>, | ||||
pub device_type: DeviceTypes, | pub device_type: DeviceTypes, | ||||
pub device_app_version: Option<String>, | pub device_app_version: Option<String>, | ||||
pub device_os: Option<String>, | pub device_os: Option<String>, | ||||
} | } | ||||
#[derive(Serialize, Deserialize)] | #[derive(Serialize, Deserialize)] | ||||
pub struct SessionResponse { | pub struct ConnectionInitializationResponse { | ||||
pub session_id: String, | pub session_id: String, | ||||
} | } | ||||
#[cfg(test)] | #[cfg(test)] | ||||
mod session_tests { | mod session_tests { | ||||
use super::*; | use super::*; | ||||
#[test] | #[test] | ||||
Show All 18 Lines |