diff options
Diffstat (limited to 'talpid_openvpn_plugin/src/processing.rs')
| -rw-r--r-- | talpid_openvpn_plugin/src/processing.rs | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/talpid_openvpn_plugin/src/processing.rs b/talpid_openvpn_plugin/src/processing.rs index 337030744e..586d0574ec 100644 --- a/talpid_openvpn_plugin/src/processing.rs +++ b/talpid_openvpn_plugin/src/processing.rs @@ -1,24 +1,36 @@ - - use ffi::OpenVpnPluginEvent; + use std::collections::HashMap; +use talpid_ipc::{IpcClient, IpcServerId}; -error_chain!{} +error_chain! { + errors { + IpcSendingError { + description("Failed while sending an event over the IPC channel") + } + } +} /// Struct processing OpenVPN events and notifies listeners over IPC -pub struct EventProcessor; +pub struct EventProcessor { + ipc_client: IpcClient<HashMap<String, String>>, +} impl EventProcessor { - pub fn new() -> Result<EventProcessor> { + pub fn new(server_id: IpcServerId) -> Result<EventProcessor> { debug!("Creating EventProcessor"); - Ok(EventProcessor) + let ipc_client = IpcClient::new(server_id); + Ok(EventProcessor { ipc_client: ipc_client }) } - pub fn process_event(&mut self, event: OpenVpnPluginEvent, _env: HashMap<String, String>) { - // TODO(linus): This is where we should send events to core. - trace!("Hello from EventProcessor: {:?}", event); + pub fn process_event(&mut self, + event: OpenVpnPluginEvent, + env: HashMap<String, String>) + -> Result<()> { + trace!("Processing \"{:?}\" event", event); + self.ipc_client.send(&env).chain_err(|| ErrorKind::IpcSendingError) } } |
