Add env var to support connecting to test servers
This commit is contained in:
parent
0f412f7334
commit
7bfbcc955c
|
@ -4,7 +4,7 @@
|
||||||
mod db;
|
mod db;
|
||||||
|
|
||||||
use grammers_client::types::{Dialog, LoginToken};
|
use grammers_client::types::{Dialog, LoginToken};
|
||||||
use grammers_client::{Client, Config};
|
use grammers_client::{Client, Config, InitParams};
|
||||||
use grammers_session::{PackedChat, Session, UpdateState};
|
use grammers_session::{PackedChat, Session, UpdateState};
|
||||||
use jni::objects::{JObject, JString};
|
use jni::objects::{JObject, JString};
|
||||||
use jni::sys::{jboolean, jint, jlong, jstring};
|
use jni::sys::{jboolean, jint, jlong, jstring};
|
||||||
|
@ -40,6 +40,7 @@ const API_ID: i32 = {
|
||||||
value
|
value
|
||||||
};
|
};
|
||||||
const API_HASH: &str = env!("TALARIA_API_HASH");
|
const API_HASH: &str = env!("TALARIA_API_HASH");
|
||||||
|
const SERVER_ADDR: &str = env!("TALARIA_SERVER_ADDR");
|
||||||
|
|
||||||
static RUNTIME: OnceCell<Runtime> = OnceCell::new();
|
static RUNTIME: OnceCell<Runtime> = OnceCell::new();
|
||||||
static CLIENT: OnceCell<Client> = OnceCell::new();
|
static CLIENT: OnceCell<Client> = OnceCell::new();
|
||||||
|
@ -114,7 +115,14 @@ async fn init_client() -> Result<()> {
|
||||||
session,
|
session,
|
||||||
api_id: API_ID,
|
api_id: API_ID,
|
||||||
api_hash: API_HASH.to_string(),
|
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?;
|
.await?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue