Skip to content

Commit

Permalink
adds update_com_msg to dummy agent
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Marsh <[email protected]>
  • Loading branch information
rytmarsh committed Mar 15, 2019
1 parent 0305463 commit 2cde89b
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 16 deletions.
7 changes: 7 additions & 0 deletions vcx/dummy-cloud-agent/src/actors/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ impl Agent {
A2AMessageV1::UpdateConfigs(msg) => self.handle_update_configs_v1(msg),
A2AMessageV1::GetConfigs(msg) => self.handle_get_configs_v1(msg),
A2AMessageV1::RemoveConfigs(msg) => self.handle_remove_configs_v1(msg),
A2AMessageV1::UpdateComMethod(msg) => self.handle_update_com_method_v1(msg),
_ => err_act!(self, err_msg("Unsupported message"))
}
.and_then(move |msgs, slf, _|
Expand Down Expand Up @@ -547,6 +548,12 @@ impl Agent {
.into_box()
}

fn handle_update_com_method_v1(&mut self, _msg: UpdateComMethod) -> ResponseActFuture<Self, Vec<A2AMessage>, Error> {
trace!("UpdateComMethod: {:?}", _msg);
let messages = vec![A2AMessage::Version1(A2AMessageV1::ComMethodUpdated(ComMethodUpdated {id: "123".to_string()}))];
ok_act!(self, messages)
}

fn handle_update_configs_v1(&mut self, msg: UpdateConfigs) -> ResponseActFuture<Self, Vec<A2AMessage>, Error> {
self.handle_update_configs(msg)
.map(|_, _, _| {
Expand Down
53 changes: 53 additions & 0 deletions vcx/dummy-cloud-agent/src/domain/a2a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ pub enum A2AMessageV1 {
Configs(Configs),
RemoveConfigs(RemoveConfigs),
ConfigsRemoved(ConfigsRemoved),
UpdateComMethod(UpdateComMethod),
ComMethodUpdated(ComMethodUpdated),
}

#[derive(Debug)]
Expand Down Expand Up @@ -93,6 +95,8 @@ pub enum A2AMessageV2 {
Configs(Configs),
RemoveConfigs(RemoveConfigs),
ConfigsRemoved(ConfigsRemoved),
UpdateComMethod(UpdateComMethod),
ComMethodUpdated(ComMethodUpdated),

ConnectionRequest(ConnectionRequest),
ConnectionRequestResponse(ConnectionRequestResponse),
Expand Down Expand Up @@ -469,6 +473,25 @@ pub struct RemoveConfigs {
#[derive(Debug, Deserialize, Serialize)]
pub struct ConfigsRemoved {}

#[derive(Debug, Deserialize, Serialize)]
pub struct ComMethod {
id: String,
#[serde(rename = "type")]
e_type: i32,
value: String,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct UpdateComMethod {
#[serde(rename = "comMethod")]
com_method: ComMethod,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct ComMethodUpdated {
pub id: String
}

#[derive(Debug, Deserialize, Serialize)]
pub struct ConnectionRequest {
#[serde(rename = "sendMsg")]
Expand Down Expand Up @@ -591,6 +614,8 @@ pub enum A2AMessageKinds {
ConnectionRequestAnswerResponse,
SendRemoteMessage,
SendRemoteMessageResponse,
UpdateComMethod,
ComMethodUpdated,
}

impl A2AMessageKinds {
Expand Down Expand Up @@ -630,6 +655,8 @@ impl A2AMessageKinds {
A2AMessageKinds::Configs => MessageFamilies::Configs,
A2AMessageKinds::RemoveConfigs => MessageFamilies::Configs,
A2AMessageKinds::ConfigsRemoved => MessageFamilies::Configs,
A2AMessageKinds::UpdateComMethod => MessageFamilies::Configs,
A2AMessageKinds::ComMethodUpdated => MessageFamilies::Configs,
A2AMessageKinds::SendRemoteMessage => MessageFamilies::Routing,
A2AMessageKinds::SendRemoteMessageResponse => MessageFamilies::Routing,
}
Expand Down Expand Up @@ -671,6 +698,8 @@ impl A2AMessageKinds {
A2AMessageKinds::Configs => "CONFIGS".to_string(),
A2AMessageKinds::RemoveConfigs => "REMOVE_CONFIGS".to_string(),
A2AMessageKinds::ConfigsRemoved => "CONFIGS_REMOVED".to_string(),
A2AMessageKinds::UpdateComMethod => "UPDATE_COM_METHOD".to_string(),
A2AMessageKinds::ComMethodUpdated => "COM_METHOD_UPDATED".to_string(),
A2AMessageKinds::SendRemoteMessage => "SEND_REMOTE_MSG".to_string(),
A2AMessageKinds::SendRemoteMessageResponse => "REMOTE_MSG_SENT".to_string(),
}
Expand Down Expand Up @@ -813,6 +842,16 @@ impl<'de> Deserialize<'de> for A2AMessageV1 {
.map(|msg| A2AMessageV1::ConfigsRemoved(msg))
.map_err(de::Error::custom)
}
"UPDATE_COM_METHOD" => {
UpdateComMethod::deserialize(value)
.map(|msg| A2AMessageV1::UpdateComMethod(msg))
.map_err(de::Error::custom)
}
"COM_METHOD_UPDATED" => {
ComMethodUpdated::deserialize(value)
.map(|msg| A2AMessageV1::ComMethodUpdated(msg))
.map_err(de::Error::custom)
}
"CREATE_MSG" => {
CreateMessage::deserialize(value)
.map(|msg| A2AMessageV1::CreateMessage(msg))
Expand Down Expand Up @@ -919,6 +958,16 @@ impl<'de> Deserialize<'de> for A2AMessageV2 {
.map(|msg| A2AMessageV2::MessageStatusUpdated(msg))
.map_err(de::Error::custom)
}
"UPDATE_COM_METHOD" => {
UpdateComMethod::deserialize(value)
.map(|msg| A2AMessageV2::UpdateComMethod(msg))
.map_err(de::Error::custom)
}
"COM_METHOD_UPDATED" => {
ComMethodUpdated::deserialize(value)
.map(|msg| A2AMessageV2::ComMethodUpdated(msg))
.map_err(de::Error::custom)
}
"GET_MSGS" => {
GetMessages::deserialize(value)
.map(|msg| A2AMessageV2::GetMessages(msg))
Expand Down Expand Up @@ -1072,6 +1121,8 @@ impl Serialize for A2AMessageV1 {
A2AMessageV1::MessageStatusUpdatedByConnections(msg) => set_a2a_message_type_v1(msg, A2AMessageKinds::MessageStatusUpdatedByConnections),
A2AMessageV1::UpdateConfigs(msg) => set_a2a_message_type_v1(msg, A2AMessageKinds::UpdateConfigs),
A2AMessageV1::ConfigsUpdated(msg) => set_a2a_message_type_v1(msg, A2AMessageKinds::ConfigsUpdated),
A2AMessageV1::UpdateComMethod(msg) => set_a2a_message_type_v1(msg, A2AMessageKinds::UpdateComMethod),
A2AMessageV1::ComMethodUpdated(msg) => set_a2a_message_type_v1(msg, A2AMessageKinds::ComMethodUpdated),
A2AMessageV1::GetConfigs(msg) => set_a2a_message_type_v1(msg, A2AMessageKinds::GetConfigs),
A2AMessageV1::Configs(msg) => set_a2a_message_type_v1(msg, A2AMessageKinds::Configs),
A2AMessageV1::RemoveConfigs(msg) => set_a2a_message_type_v1(msg, A2AMessageKinds::RemoveConfigs),
Expand Down Expand Up @@ -1112,6 +1163,8 @@ impl Serialize for A2AMessageV2 {
A2AMessageV2::MessageStatusUpdatedByConnections(msg) => set_a2a_message_type_v2(msg, A2AMessageKinds::MessageStatusUpdatedByConnections),
A2AMessageV2::UpdateConfigs(msg) => set_a2a_message_type_v2(msg, A2AMessageKinds::UpdateConfigs),
A2AMessageV2::ConfigsUpdated(msg) => set_a2a_message_type_v2(msg, A2AMessageKinds::ConfigsUpdated),
A2AMessageV2::UpdateComMethod(msg) => set_a2a_message_type_v2(msg, A2AMessageKinds::UpdateComMethod),
A2AMessageV2::ComMethodUpdated(msg) => set_a2a_message_type_v2(msg, A2AMessageKinds::ComMethodUpdated),
A2AMessageV2::GetConfigs(msg) => set_a2a_message_type_v2(msg, A2AMessageKinds::GetConfigs),
A2AMessageV2::Configs(msg) => set_a2a_message_type_v2(msg, A2AMessageKinds::Configs),
A2AMessageV2::RemoveConfigs(msg) => set_a2a_message_type_v2(msg, A2AMessageKinds::RemoveConfigs),
Expand Down
2 changes: 1 addition & 1 deletion vcx/libvcx/src/messages/agent_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub struct CreateAgentResponse {
}

#[derive(Serialize, Deserialize, Debug)]
pub struct UpdateComMethodResponse {
pub struct ComMethodUpdated {
#[serde(rename = "@type")]
msg_type: MessageTypes,
id: String
Expand Down
33 changes: 18 additions & 15 deletions vcx/libvcx/src/messages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use self::get_message::{GetMessagesBuilder, GetMessages, GetMessagesResponse, Me
use self::send_message::SendMessageBuilder;
use self::update_message::{UpdateMessageStatusByConnections, UpdateMessageStatusByConnectionsResponse};
use self::proofs::proof_request::ProofRequestMessage;
use self::agent_utils::{Connect, ConnectResponse, SignUp, SignUpResponse, CreateAgent, CreateAgentResponse, UpdateComMethod, UpdateComMethodResponse};
use self::agent_utils::{Connect, ConnectResponse, SignUp, SignUpResponse, CreateAgent, CreateAgentResponse, UpdateComMethod, ComMethodUpdated};
use self::message_type::*;
use error::prelude::*;

Expand Down Expand Up @@ -69,7 +69,7 @@ pub enum A2AMessageV1 {
UpdateConfigs(UpdateConfigs),
UpdateConfigsResponse(UpdateConfigsResponse),
UpdateComMethod(UpdateComMethod),
UpdateComMethodResponse(UpdateComMethodResponse),
ComMethodUpdated(ComMethodUpdated),
}

impl<'de> Deserialize<'de> for A2AMessageV1 {
Expand Down Expand Up @@ -119,8 +119,8 @@ impl<'de> Deserialize<'de> for A2AMessageV1 {
.map_err(de::Error::custom)
}
"COM_METHOD_UPDATED" => {
UpdateComMethodResponse::deserialize(value)
.map(|msg| A2AMessageV1::UpdateComMethodResponse(msg))
ComMethodUpdated::deserialize(value)
.map(|msg| A2AMessageV1::ComMethodUpdated(msg))
.map_err(de::Error::custom)
}
"CREATE_KEY" => {
Expand Down Expand Up @@ -248,7 +248,7 @@ pub enum A2AMessageV2 {
UpdateConfigs(UpdateConfigs),
UpdateConfigsResponse(UpdateConfigsResponse),
UpdateComMethod(UpdateComMethod),
UpdateComMethodResponse(UpdateComMethodResponse),
ComMethodUpdated(ComMethodUpdated),
}

impl<'de> Deserialize<'de> for A2AMessageV2 {
Expand Down Expand Up @@ -292,16 +292,6 @@ impl<'de> Deserialize<'de> for A2AMessageV2 {
.map(|msg| A2AMessageV2::CreateAgentResponse(msg))
.map_err(de::Error::custom)
}
"UPDATE_COM_METHOD" => {
UpdateComMethod::deserialize(value)
.map(|msg| A2AMessageV2::UpdateComMethod(msg))
.map_err(de::Error::custom)
}
"COM_METHOD_UPDATED" => {
UpdateComMethodResponse::deserialize(value)
.map(|msg| A2AMessageV2::UpdateComMethodResponse(msg))
.map_err(de::Error::custom)
}
"CREATE_KEY" => {
CreateKey::deserialize(value)
.map(|msg| A2AMessageV2::CreateKey(msg))
Expand Down Expand Up @@ -392,6 +382,16 @@ impl<'de> Deserialize<'de> for A2AMessageV2 {
.map(|msg| A2AMessageV2::UpdateConfigsResponse(msg))
.map_err(de::Error::custom)
}
"UPDATE_COM_METHOD" => {
UpdateComMethod::deserialize(value)
.map(|msg| A2AMessageV2::UpdateComMethod(msg))
.map_err(de::Error::custom)
}
"COM_METHOD_UPDATED" => {
ComMethodUpdated::deserialize(value)
.map(|msg| A2AMessageV2::ComMethodUpdated(msg))
.map_err(de::Error::custom)
}
_ => Err(de::Error::custom("Unexpected @type field structure."))
}
}
Expand Down Expand Up @@ -641,6 +641,7 @@ pub enum A2AMessageKinds {
UpdateConfigs,
ConfigsUpdated,
UpdateComMethod,
ComMethodUpdated,
ConnectionRequest,
ConnectionRequestAnswer,
SendRemoteMessage,
Expand Down Expand Up @@ -674,6 +675,7 @@ impl A2AMessageKinds {
A2AMessageKinds::UpdateConfigs => MessageFamilies::Configs,
A2AMessageKinds::ConfigsUpdated => MessageFamilies::Configs,
A2AMessageKinds::UpdateComMethod => MessageFamilies::Configs,
A2AMessageKinds::ComMethodUpdated => MessageFamilies::Configs,
A2AMessageKinds::SendRemoteMessage => MessageFamilies::Routing,
A2AMessageKinds::SendRemoteMessageResponse => MessageFamilies::Routing,
}
Expand Down Expand Up @@ -705,6 +707,7 @@ impl A2AMessageKinds {
A2AMessageKinds::UpdateConfigs => "UPDATE_CONFIGS".to_string(),
A2AMessageKinds::ConfigsUpdated => "CONFIGS_UPDATED".to_string(),
A2AMessageKinds::UpdateComMethod => "UPDATE_COM_METHOD".to_string(),
A2AMessageKinds::ComMethodUpdated => "COM_METHOD_UPDATED".to_string(),
A2AMessageKinds::SendRemoteMessage => "SEND_REMOTE_MSG".to_string(),
A2AMessageKinds::SendRemoteMessageResponse => "REMOTE_MSG_SENT".to_string(),
}
Expand Down

0 comments on commit 2cde89b

Please sign in to comment.