pub struct CbskClient {
pub header: Arc<Vec<u8>>,
/* private fields */
}
Expand description
cbsk client
Fields§
§header: Arc<Vec<u8>>
cbsk header
Implementations§
Source§impl CbskClient
custom method
impl CbskClient
custom method
Sourcepub fn new<C: CbskClientCallBack>(
cb: Arc<C>,
addr: SocketAddr,
buf_len: usize,
) -> Self
pub fn new<C: CbskClientCallBack>( cb: Arc<C>, addr: SocketAddr, buf_len: usize, ) -> Self
new cbsk client
if the tcp connection is disconnected, it will reconnect after 3 seconds
Sourcepub fn new_with_tcp_config<C: CbskClientCallBack>(
cb: Arc<C>,
conf: Arc<TcpClientConfig>,
buf_len: usize,
) -> Self
pub fn new_with_tcp_config<C: CbskClientCallBack>( cb: Arc<C>, conf: Arc<TcpClientConfig>, buf_len: usize, ) -> Self
use tcp client config create cbsk client
Sourcepub fn new_with_header<C: CbskClientCallBack>(
cb: Arc<C>,
addr: SocketAddr,
header: Vec<u8>,
buf_len: usize,
) -> Self
pub fn new_with_header<C: CbskClientCallBack>( cb: Arc<C>, addr: SocketAddr, header: Vec<u8>, buf_len: usize, ) -> Self
custom header create cbsk client
Sourcepub fn new_with_htc<C: CbskClientCallBack>(
cb: Arc<C>,
header: Vec<u8>,
conf: Arc<TcpClientConfig>,
buf_len: usize,
) -> Self
pub fn new_with_htc<C: CbskClientCallBack>( cb: Arc<C>, header: Vec<u8>, conf: Arc<TcpClientConfig>, buf_len: usize, ) -> Self
htc is an abbreviation for header_tcp_config
Sourcepub fn default_tcp_config(addr: SocketAddr) -> TcpClientConfig
pub fn default_tcp_config(addr: SocketAddr) -> TcpClientConfig
get default tcp config
Sourcepub fn start_in_handle(&self) -> JoinHandle<()>
pub fn start_in_handle(&self) -> JoinHandle<()>
start cbsk client in join handle
Sourcepub async fn is_connected(&self) -> bool
pub async fn is_connected(&self) -> bool
get has the cbsk server connection been success
Sourcepub async fn stop(&self)
pub async fn stop(&self)
stop cbsk server connect
will shutdown tcp connection and will not new connection
Sourcepub async fn re_conn(&self)
pub async fn re_conn(&self)
notify tcp to re connect
will shutdown tcp connection, if TcpClientConfig
reconn is disable
will shutdown and create new tcp connection,if TcpClientConfig
reconn is enable
Sourcepub fn get_recv_time(&self) -> i64
pub fn get_recv_time(&self) -> i64
the last time the data was received
Sourcepub fn get_config(&self) -> Arc<TcpClientConfig>
pub fn get_config(&self) -> Arc<TcpClientConfig>
get tcp config
Trait Implementations§
Source§impl CbskWriteTrait for CbskClient
support write data to cbsk
impl CbskWriteTrait for CbskClient
support write data to cbsk
Source§impl TimeTrait for CbskClient
support time trait
impl TimeTrait for CbskClient
support time trait
Source§fn set_recv_time(&self, time: i64)
fn set_recv_time(&self, time: i64)
set the last time the data was received for tcp
Source§fn get_recv_time(&self) -> i64
fn get_recv_time(&self) -> i64
get the last time the data was received for tcp
Source§fn set_timeout_time(&self, time: i64)
fn set_timeout_time(&self, time: i64)
set tcp last read timeout
Source§fn get_timeout_time(&self) -> i64
fn get_timeout_time(&self) -> i64
get tcp last read timeout
Source§fn set_wait_callback(&self, is_wait: bool)
fn set_wait_callback(&self, is_wait: bool)
set is wait callback
Source§fn get_wait_callback(&self) -> bool
fn get_wait_callback(&self) -> bool
get is wait callback
Source§fn set_ignore_once(&self, is_ignore: bool)
fn set_ignore_once(&self, is_ignore: bool)
set ignore once time check
Source§fn get_ignore(&self) -> bool
fn get_ignore(&self) -> bool
get ignore
Source§fn set_recv_time_now(&self)
fn set_recv_time_now(&self)
set recv time to now
Source§fn set_timeout_time_now(&self)
fn set_timeout_time_now(&self)
set timeout time to now
Source§fn wait_callback(&self)
fn wait_callback(&self)
need wait callback finish business logic
Source§fn finish_callback(&self)
fn finish_callback(&self)
callback the business logic has been completed
Auto Trait Implementations§
impl Freeze for CbskClient
impl !RefUnwindSafe for CbskClient
impl Send for CbskClient
impl Sync for CbskClient
impl Unpin for CbskClient
impl !UnwindSafe for CbskClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more