diff options
Diffstat (limited to 'crates/vcs_actions/src/actions')
| -rw-r--r-- | crates/vcs_actions/src/actions/local_actions.rs | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/crates/vcs_actions/src/actions/local_actions.rs b/crates/vcs_actions/src/actions/local_actions.rs index 0e210a7..b11a934 100644 --- a/crates/vcs_actions/src/actions/local_actions.rs +++ b/crates/vcs_actions/src/actions/local_actions.rs @@ -1,17 +1,25 @@ -use std::net::SocketAddr; - use action_system::{action::ActionContext, action_gen}; +use log::info; use tcp_connection::error::TcpTargetError; -#[action_gen(local)] -pub async fn set_upstream_vault_action( - ctx: ActionContext, - _upstream: SocketAddr, -) -> Result<(), TcpTargetError> { - if ctx.is_remote() { - return Err(TcpTargetError::NotLocal( - "Action was not invoked on the local machine".to_string(), +#[action_gen] +pub async fn hello_world_action(ctx: ActionContext, _n: ()) -> Result<(), TcpTargetError> { + // Ensure the instance is available + let Some(instance) = ctx.instance() else { + return Err(TcpTargetError::NotFound( + "Connection Instance Lost.".to_string(), )); + }; + + if ctx.is_local() { + // Invoke on local + // Send the message to the server + let _ = instance.lock().await.write_text("Hello World!").await; + } else if ctx.is_remote() { + // Read the message from the client + let read = instance.lock().await.read_text().await?; + info!("{}", read) } + Ok(()) } |
