Add env var to support connecting to test servers

This commit is contained in:
Lonami Exo 2022-10-20 21:18:56 +02:00
parent 0f412f7334
commit 7bfbcc955c
1 changed files with 10 additions and 2 deletions

View File

@ -4,7 +4,7 @@
mod db;
use grammers_client::types::{Dialog, LoginToken};
use grammers_client::{Client, Config};
use grammers_client::{Client, Config, InitParams};
use grammers_session::{PackedChat, Session, UpdateState};
use jni::objects::{JObject, JString};
use jni::sys::{jboolean, jint, jlong, jstring};
@ -40,6 +40,7 @@ const API_ID: i32 = {
value
};
const API_HASH: &str = env!("TALARIA_API_HASH");
const SERVER_ADDR: &str = env!("TALARIA_SERVER_ADDR");
static RUNTIME: OnceCell<Runtime> = OnceCell::new();
static CLIENT: OnceCell<Client> = OnceCell::new();
@ -114,7 +115,14 @@ async fn init_client() -> Result<()> {
session,
api_id: API_ID,
api_hash: API_HASH.to_string(),
params: Default::default(),
params: InitParams {
server_addr: if SERVER_ADDR.is_empty() {
None
} else {
Some(SERVER_ADDR.parse().unwrap())
},
..Default::default()
},
})
.await?;