|
|
@ -157,6 +157,14 @@ struct Match {
|
|
|
|
|
|
|
|
|
|
|
|
struct TMClient {
|
|
|
|
struct TMClient {
|
|
|
|
notices: mpsc::Sender<tm::Notice>,
|
|
|
|
notices: mpsc::Sender<tm::Notice>,
|
|
|
|
|
|
|
|
requests: mpsc::Receiver<tm::Notice>,
|
|
|
|
|
|
|
|
responses: mpsc::Sender<tm::Notice>,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct TMConnection {
|
|
|
|
|
|
|
|
notices: mpsc::Receiver<tm::Notice>,
|
|
|
|
|
|
|
|
requests: mpsc::Sender<tm::Notice>,
|
|
|
|
|
|
|
|
responses: mpsc::Receiver<tm::Notice>,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct BackendMessage {
|
|
|
|
struct BackendMessage {
|
|
|
@ -164,11 +172,20 @@ struct BackendMessage {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl TMClient {
|
|
|
|
impl TMClient {
|
|
|
|
fn new() -> (TMClient, mpsc::Receiver<tm::Notice>) {
|
|
|
|
fn new() -> (TMClient, TMConnection) {
|
|
|
|
let (tx, rx) = mpsc::channel();
|
|
|
|
let (notice_tx, notice_rx) = mpsc::channel();
|
|
|
|
|
|
|
|
let (request_tx, request_rx) = mpsc::channel();
|
|
|
|
|
|
|
|
let (response_tx, response_rx) = mpsc::channel();
|
|
|
|
(TMClient{
|
|
|
|
(TMClient{
|
|
|
|
notices: tx,
|
|
|
|
notices: notice_tx,
|
|
|
|
}, rx)
|
|
|
|
requests: request_rx,
|
|
|
|
|
|
|
|
responses: response_tx
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
TMConnection{
|
|
|
|
|
|
|
|
notices: notice_rx,
|
|
|
|
|
|
|
|
requests: request_tx,
|
|
|
|
|
|
|
|
responses: response_rx
|
|
|
|
|
|
|
|
},)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn process(self: &TMClient) {
|
|
|
|
fn process(self: &TMClient) {
|
|
|
@ -321,7 +338,7 @@ fn main() {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
let running = true;
|
|
|
|
let running = true;
|
|
|
|
let (tm_client, tm_notices) = TMClient::new();
|
|
|
|
let (tm_client, tm_connection) = TMClient::new();
|
|
|
|
let tm_thread = thread::spawn(move ||
|
|
|
|
let tm_thread = thread::spawn(move ||
|
|
|
|
while running {
|
|
|
|
while running {
|
|
|
|
tm_client.process();
|
|
|
|
tm_client.process();
|
|
|
@ -329,7 +346,7 @@ fn main() {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
while running {
|
|
|
|
while running {
|
|
|
|
match tm_notices.recv() {
|
|
|
|
match tm_connection.notices.recv() {
|
|
|
|
Ok(notice) => {
|
|
|
|
Ok(notice) => {
|
|
|
|
let callback = callbacks.get(¬ice.id());
|
|
|
|
let callback = callbacks.get(¬ice.id());
|
|
|
|
match callback {
|
|
|
|
match callback {
|
|
|
|