Move stream build logic to Client, fix client data reading and screen size parsing

This commit is contained in:
Tim Visée
2017-12-31 21:01:39 +01:00
parent 316fb11b4c
commit b0d684738a
5 changed files with 149 additions and 42 deletions

View File

@@ -1,5 +1,3 @@
use std::io::Error;
use std::net::TcpStream;
use std::sync::mpsc;
use std::sync::mpsc::{Sender, Receiver};
use std::thread;
@@ -83,19 +81,16 @@ impl Canvas {
// Create the painter thread
let thread = thread::spawn(move || {
// Create a new stream
let stream = create_stream(host)
.expect("failed to open stream to pixelflut");
// Create a new client
let client = Client::new(stream);
let client = Client::connect(host)
.expect("failed to open stream to pixelflut");
// Create a painter
let mut painter = Painter::new(
client,
area,
offset,
None
None,
);
// Do some work
@@ -129,12 +124,3 @@ impl Canvas {
}
}
}
/// Create a stream to talk to the pixelflut server.
///
/// The stream is returned as result.
fn create_stream(host: String) -> Result<TcpStream, Error> {
TcpStream::connect(host)
}