Skip to content
14 changes: 13 additions & 1 deletion core/sdk/src/extn/client/extn_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use log::{debug, error, info, trace};
use std::{
collections::HashMap,
ops::ControlFlow,
sync::{Arc, RwLock},
sync::{mpsc::Sender, Arc, RwLock},
};
use tokio_tungstenite::tungstenite::Message;

Expand Down Expand Up @@ -127,6 +127,18 @@ impl ExtnClient {
}
}

pub fn new_main_with_sender(sender: tokio::sync::mpsc::Sender<ApiMessage>) -> ExtnClient {
Self {
sender: ExtnSender::new_main_with_sender(sender),
extn_sender_map: Arc::new(RwLock::new(HashMap::new())),
contract_map: Arc::new(RwLock::new(HashMap::new())),
response_processors: Arc::new(RwLock::new(HashMap::new())),
request_processors: Arc::new(RwLock::new(HashMap::new())),
event_processors: Arc::new(RwLock::new(HashMap::new())),
ripple_context: Arc::new(RwLock::new(RippleContext::default())),
}
}

pub fn new_extn(symbol: ExtnSymbol) -> (ExtnClient, mpsc::Receiver<ApiMessage>) {
let (tx, tr) = mpsc::channel::<ApiMessage>(32);
let client = Self {
Expand Down
10 changes: 10 additions & 0 deletions core/sdk/src/extn/client/extn_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ impl ExtnSender {
}
}

pub fn new_main_with_sender(sender: Sender<ApiMessage>) -> Self {
ExtnSender {
tx: Some(sender),
id: ExtnId::get_main_target("main".to_owned()),
permitted: Vec::default(),
fulfills: Vec::default(),
config: None,
}
}

pub fn new_extn(tx: Sender<ApiMessage>, symbol: ExtnSymbol) -> Self {
ExtnSender {
tx: Some(tx),
Expand Down
5 changes: 0 additions & 5 deletions device/thunder/src/bootstrap/boot_thunder_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,13 @@

use thunder_ripple_sdk::{
bootstrap::boot_thunder::boot_thunder,
client::plugin_manager::{ThunderPluginBootParam, ThunderPluginParam},
ripple_sdk::{extn::client::extn_client::ExtnClient, log::info},
};

pub async fn boot_thunder_channel(state: ExtnClient) {
info!("Booting thunder");
let _ = boot_thunder(
state,
ThunderPluginBootParam {
activate_on_boot: ThunderPluginParam::Default,
expected: ThunderPluginParam::Default,
},
)
.await;
}
15 changes: 3 additions & 12 deletions device/thunder_ripple_sdk/src/bootstrap/boot_thunder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

use crate::{
bootstrap::setup_thunder_processors::SetupThunderProcessor,
client::plugin_manager::ThunderPluginBootParam, thunder_state::ThunderBootstrapStateWithClient,
thunder_state::ThunderBootstrapStateWithClient,
};
use ripple_sdk::{
api::manifest::device_manifest::DeviceManifest,
Expand Down Expand Up @@ -45,7 +45,6 @@ fn gateway_default() -> String {

pub async fn boot_thunder(
ext_client: ExtnClient,
_plugin_param: ThunderPluginBootParam,
device_manifest: &DeviceManifest,
) -> Option<ThunderBootstrapStateWithClient> {
info!("Booting thunder initiated");
Expand Down Expand Up @@ -94,16 +93,8 @@ pub async fn boot_thunder(
gateway_url.set_host(Some(&host_override)).ok();
}

if let Ok(thndr_client) = ThunderClientBuilder::start_thunder_client(
gateway_url.clone(),
None,
None,
None,
None,
true,
status_check,
)
.await
if let Ok(thndr_client) =
ThunderClientBuilder::start_thunder_client(gateway_url.clone(), status_check).await
{
let thunder_state = ThunderState::new(ext_client.clone(), thndr_client);

Expand Down
105 changes: 0 additions & 105 deletions device/thunder_ripple_sdk/src/bootstrap/get_config_step.rs

This file was deleted.

146 changes: 0 additions & 146 deletions device/thunder_ripple_sdk/src/bootstrap/setup_thunder_pool_step.rs

This file was deleted.

28 changes: 27 additions & 1 deletion device/thunder_ripple_sdk/src/client/device_operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub trait DeviceOperator: Clone {
handler: mpsc::Sender<DeviceResponseMessage>,
) -> Result<DeviceResponseMessage, RecvError>;

async fn unsubscribe(&self, request: DeviceUnsubscribeRequest);
//async fn unsubscribe(&self, request: DeviceUnsubscribeRequest); //not used anywhere commented out for now.
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -91,6 +91,32 @@ impl DeviceChannelRequest {
}
}
}

// <pca>
pub fn get_dev_call_request(&self) -> Option<DeviceCallRequest> {
if let DeviceChannelRequest::Call(c) = self {
Some(c.clone())
} else {
None
}
}

pub fn get_dev_subscribe_request(&self) -> Option<DeviceSubscribeRequest> {
if let DeviceChannelRequest::Subscribe(s) = self {
Some(s.clone())
} else {
None
}
}

pub fn get_dev_unsubscribe_request(&self) -> Option<DeviceUnsubscribeRequest> {
if let DeviceChannelRequest::Unsubscribe(u) = self {
Some(u.clone())
} else {
None
}
}
// </pca>
}

#[derive(Debug, Clone)]
Expand Down
Loading