Misc changes.

This commit is contained in:
Paul Makles
2020-02-16 16:31:23 +00:00
parent 0471ba6a6f
commit a763c8cb58
8 changed files with 126 additions and 26 deletions

View File

@@ -40,6 +40,8 @@ impl Handler for Server {
if let Some(_) = self.id {
self.out.send(
json!({
"type": "authenticate",
"success": false,
"error": "Already authenticated!"
})
.to_string()
@@ -71,6 +73,7 @@ impl Handler for Server {
self.id = Some(id.to_string());
self.out.send(
json!({
"type": "authenticate",
"success": true
})
.to_string()
@@ -79,6 +82,8 @@ impl Handler for Server {
None =>
self.out.send(
json!({
"type": "authenticate",
"success": false,
"error": "Invalid authentication token."
})
.to_string()
@@ -87,6 +92,8 @@ impl Handler for Server {
} else {
self.out.send(
json!({
"type": "authenticate",
"success": false,
"error": "Missing authentication token."
})
.to_string()
@@ -141,7 +148,7 @@ pub fn launch_server() {
}
}
listen("127.0.0.1:3012", |out| { Server { out: out, id: None, internal: Ulid::new().to_string() } }).unwrap()
listen("192.168.0.10:9999", |out| { Server { out: out, id: None, internal: Ulid::new().to_string() } }).unwrap()
}
pub fn send_message(id: String, message: String) -> std::result::Result<(), ()> {