Merge pull request #933 from ethcore/ipc-prs-client
IPC persistent client link
This commit is contained in:
@@ -9,3 +9,4 @@ license = "GPL-3.0"
|
||||
[dependencies]
|
||||
ethcore-devtools = { path = "../../devtools" }
|
||||
semver = "0.2.0"
|
||||
nanomsg = "0.5.0"
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
use std::io::{Read, Write};
|
||||
use std::marker::Sync;
|
||||
use std::sync::atomic::*;
|
||||
use semver::Version;
|
||||
|
||||
pub struct Handshake {
|
||||
@@ -49,7 +48,7 @@ pub enum Error {
|
||||
HandshakeFailed,
|
||||
}
|
||||
|
||||
pub trait IpcInterface<T> where T: IpcConfig {
|
||||
pub trait IpcInterface<T>: IpcConfig {
|
||||
/// reads the message from io, dispatches the call and returns serialized result
|
||||
fn dispatch<R>(&self, r: &mut R) -> Vec<u8> where R: Read;
|
||||
|
||||
@@ -72,6 +71,7 @@ pub fn invoke<W>(method_num: u16, params: &Option<Vec<u8>>, w: &mut W) where W:
|
||||
if params.is_some() {
|
||||
buf[2..buf_len].clone_from_slice(params.as_ref().unwrap());
|
||||
}
|
||||
|
||||
if w.write(&buf).unwrap() != buf_len
|
||||
{
|
||||
// if write was inconsistent
|
||||
@@ -83,5 +83,12 @@ pub fn invoke<W>(method_num: u16, params: &Option<Vec<u8>>, w: &mut W) where W:
|
||||
pub trait IpcSocket: Read + Write + Sync {
|
||||
}
|
||||
|
||||
impl IpcSocket for ::devtools::TestSocket {
|
||||
|
||||
pub trait WithSocket<S: IpcSocket> {
|
||||
fn init(socket: S) -> Self;
|
||||
}
|
||||
|
||||
|
||||
impl IpcSocket for ::devtools::TestSocket {}
|
||||
|
||||
impl IpcSocket for ::nanomsg::Socket {}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
extern crate ethcore_devtools as devtools;
|
||||
extern crate semver;
|
||||
extern crate nanomsg;
|
||||
|
||||
pub mod interface;
|
||||
pub use interface::{IpcInterface, IpcSocket, invoke, IpcConfig, Handshake, Error};
|
||||
pub use interface::{IpcInterface, IpcSocket, invoke, IpcConfig, Handshake, Error, WithSocket};
|
||||
|
||||
Reference in New Issue
Block a user