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