Continue hacking away reimplementing server

This commit is contained in:
Lucien Greathouse 2018-08-19 20:16:38 -07:00
parent 2b808b12fe
commit 2a4704f5b0
2 changed files with 21 additions and 23 deletions

View file

@ -1,36 +1,34 @@
use std::path::Path; use std::{
use std::process; path::Path,
use std::fs; process,
sync::Arc,
};
use rand; use ::{
project::Project,
use project::Project; web::Server,
// use web::{self, WebConfig}; serve_session::ServeSession,
// use session::Session; roblox_studio,
use roblox_studio; };
pub fn serve(fuzzy_project_location: &Path) { pub fn serve(fuzzy_project_location: &Path) {
let server_id = rand::random::<u64>();
let project = match Project::load_fuzzy(fuzzy_project_location) { let project = match Project::load_fuzzy(fuzzy_project_location) {
Ok(project) => { Ok(project) => project,
println!("Using project from {}", fs::canonicalize(&project.file_location).unwrap().display());
project
},
Err(error) => { Err(error) => {
eprintln!("{}", error); eprintln!("Fatal: {}", error);
process::exit(1); process::exit(1);
}, },
}; };
println!("Found project at {}", project.file_location.display());
println!("Using project {:#?}", project); println!("Using project {:#?}", project);
roblox_studio::install_bundled_plugin().unwrap(); roblox_studio::install_bundled_plugin().unwrap();
// let mut session = Session::new(project.clone()); let session = Arc::new(ServeSession::new(project));
// session.start(); let server = Server::new(Arc::from(session));
// let web_config = WebConfig::from_session(server_id, port, &session); println!("Server listening on port 8000.");
// web::start(web_config); server.listen(8000);
} }

View file

@ -1,13 +1,13 @@
use std::borrow::Cow; use std::borrow::Cow;
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::{mpsc, RwLock, Arc}; use std::sync::{mpsc, Arc};
use rouille::{self, Request, Response}; use rouille::{self, Request, Response};
use rand; use rand;
use ::{ use ::{
id::Id, id::Id,
message_session::{MessageSession, Message}, message_session::Message,
project::Project, project::Project,
rbx::RbxInstance, rbx::RbxInstance,
serve_session::ServeSession, serve_session::ServeSession,
@ -56,6 +56,7 @@ impl Server {
} }
} }
#[allow(unreachable_code)]
pub fn handle_request(&self, request: &Request) -> Response { pub fn handle_request(&self, request: &Request) -> Response {
router!(request, router!(request,
(GET) (/) => { (GET) (/) => {
@ -153,7 +154,6 @@ impl Server {
) )
} }
// #[allow(unreachable_code)]
pub fn listen(self, port: u64) { pub fn listen(self, port: u64) {
let address = format!("localhost:{}", port); let address = format!("localhost:{}", port);