@@ -47,4 +47,14 @@ impl<S> Net for NetClient<S> where S: SyncProvider + 'static {
|
||||
// right now (11 march 2016), we are always listening for incoming connections
|
||||
Ok(Value::Bool(true))
|
||||
}
|
||||
|
||||
fn start_network(&self, _: Params) -> Result<Value, Error> {
|
||||
take_weak!(self.sync).start_network();
|
||||
Ok(Value::Bool(true))
|
||||
}
|
||||
|
||||
fn stop_network(&self, _: Params) -> Result<Value, Error> {
|
||||
take_weak!(self.sync).stop_network();
|
||||
Ok(Value::Bool(true))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,5 +59,11 @@ impl SyncProvider for TestSyncProvider {
|
||||
fn status(&self) -> SyncStatus {
|
||||
self.status.read().unwrap().clone()
|
||||
}
|
||||
|
||||
fn start_network(&self) {
|
||||
}
|
||||
|
||||
fn stop_network(&self) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,12 @@ pub trait Net: Sized + Send + Sync + 'static {
|
||||
/// Otherwise false.
|
||||
fn is_listening(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Start the network.
|
||||
fn start_network(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Stop the network.
|
||||
fn stop_network(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Should be used to convert object to io delegate.
|
||||
fn to_delegate(self) -> IoDelegate<Self> {
|
||||
let mut delegate = IoDelegate::new(Arc::new(self));
|
||||
|
||||
Reference in New Issue
Block a user