Skip to content

Commit

Permalink
Merge branch 'master' into clen-1237/add-stateless-receive-methods
Browse files Browse the repository at this point in the history
  • Loading branch information
parfeon committed Jul 25, 2023
2 parents e992965 + 3de77c6 commit bcbf222
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ required-features = ["default", "parse_token", "access"]
name = "pam_blocking"
required-features = ["default", "blocking", "access"]

[[example]]
name = "custom_origin"
required-features = ["default"]

[[example]]
name = "subscribe"
required-features = ["default", "subscribe"]
Expand Down
38 changes: 38 additions & 0 deletions examples/custom_origin.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
use pubnub::{transport::TransportReqwest, Keyset, PubNubClientBuilder};
use std::env;

#[tokio::main]
async fn main() -> Result<(), Box<dyn snafu::Error>> {
let publish_key = env::var("SDK_PUB_KEY")?;
let subscribe_key = env::var("SDK_SUB_KEY")?;

let transport = {
let mut transport = TransportReqwest::default();

// this is the default server, change it to your custom origin
transport.set_hostname("https://ps.pndsn.com");

transport
};

let client = PubNubClientBuilder::with_transport(transport)
.with_keyset(Keyset {
subscribe_key,
publish_key: Some(publish_key),
secret_key: None,
})
.with_user_id("user_id")
.build()?;

// publish to check the custom origin
let result = client
.publish_message("hello world!")
.channel("my_channel")
.r#type("text-message")
.execute()
.await?;

println!("publish result: {:?}", result);

Ok(())
}
2 changes: 1 addition & 1 deletion src/dx/subscribe/event_engine/effect_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ impl Debug for SubscribeEffectHandler {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(f, "SubscribeEffectHandler {{}}")
}
}
}
4 changes: 2 additions & 2 deletions src/dx/subscribe/event_engine/effects/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{
use async_channel::Sender;
use futures::future::BoxFuture;

mod emit_messagess;
mod emit_messages;
mod emit_status;
mod handshake;
mod handshake_reconnection;
Expand Down Expand Up @@ -320,7 +320,7 @@ impl Effect for SubscribeEffect {
emit_status::execute(status.clone(), executor).await
}
SubscribeEffect::EmitMessages { updates, executor } => {
emit_messagess::execute(updates.clone(), executor).await
emit_messages::execute(updates.clone(), executor).await
}
}
}
Expand Down

0 comments on commit bcbf222

Please sign in to comment.