Struct dingtalk_stream_sdk_rust::Client
source · pub struct Client {
pub config: Arc<Mutex<ClientConfig>>,
/* private fields */
}
Expand description
An asynchronous Client
to interactive with DingTalk server
Using websocket fro receiving message and https for sending
Fields§
§config: Arc<Mutex<ClientConfig>>
config inside client can be adjusted
Implementations§
source§impl Client
impl Client
sourcepub async fn create_group(&self, req: CreateRequest) -> Result<(String, String)>
pub async fn create_group(&self, req: CreateRequest) -> Result<(String, String)>
create group via CreateRequest
, return group (open_conversation_id, chatid)
source§impl Client
impl Client
source§impl Client
impl Client
sourcepub fn new(
client_id: impl Into<String>,
client_secret: impl Into<String>
) -> Result<Arc<Self>>
pub fn new( client_id: impl Into<String>, client_secret: impl Into<String> ) -> Result<Arc<Self>>
Create new client, need to specific the id and secret they provided when creating the robot
sourcepub fn keep_alive(self: Arc<Self>, value: i64) -> Arc<Self>
pub fn keep_alive(self: Arc<Self>, value: i64) -> Arc<Self>
Control client side keep alive heartbeat interval(ms), default is 8000.
When set to 0, means disable keep alive heartbeat.
sourcepub fn reconnect(self: Arc<Self>, value: i64) -> Arc<Self>
pub fn reconnect(self: Arc<Self>, value: i64) -> Arc<Self>
Control client reconnect when websocket disconnected(ms), default is 1000ms.
When set to 0, means disable reconnect.
sourcepub fn register_all_event_listener<P>(
self: Arc<Self>,
on_event_received: P
) -> Arc<Self>
pub fn register_all_event_listener<P>( self: Arc<Self>, on_event_received: P ) -> Arc<Self>
Add listener to watch all event.
Calling this interface multiple times will replace the old listener with a new one.
sourcepub fn register_callback_listener<P, F>(
self: Arc<Self>,
event_id: impl AsRef<str>,
callback: P
) -> Arc<Self>
pub fn register_callback_listener<P, F>( self: Arc<Self>, event_id: impl AsRef<str>, callback: P ) -> Arc<Self>
Add listener to watch specifc event id
sourcepub async fn connect(self: Arc<Self>) -> Result<()>
pub async fn connect(self: Arc<Self>) -> Result<()>
Connect to api gateway, and begin the websocket stream process