Mercurial > tablet-emu
annotate src/server.rs @ 14:adab13145994
Add support for remote clients.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Mon, 02 Nov 2020 00:06:09 +0100 |
parents | |
children | d103f7cca0bd |
rev | line source |
---|---|
14
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
1 // Tablet emulator, for people who don’t own one |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
2 // Copyright © 2020 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
3 // |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
4 // This program is free software: you can redistribute it and/or modify |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
5 // it under the terms of the GNU Affero General Public License as published by |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
6 // the Free Software Foundation, either version 3 of the License, or |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
7 // (at your option) any later version. |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
8 // |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
9 // This program is distributed in the hope that it will be useful, |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
12 // GNU Affero General Public License for more details. |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
13 // |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
14 // You should have received a copy of the GNU Affero General Public License |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
15 // along with this program. If not, see <https://www.gnu.org/licenses/>. |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
16 |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
17 use std::net::UdpSocket; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
18 use std::io::{self, ErrorKind}; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
19 use crate::state::State; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
20 use bitflags::bitflags; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
21 use input_linux::Key; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
22 |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
23 bitflags! { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
24 /// This is the memory layout of the buttons on the 3DS. |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
25 #[derive(Default)] |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
26 struct Buttons: u32 { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
27 const A = 0x00000001; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
28 const B = 0x00000002; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
29 const SELECT = 0x00000004; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
30 const START = 0x00000008; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
31 const RIGHT = 0x00000010; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
32 const LEFT = 0x00000020; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
33 const UP = 0x00000040; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
34 const DOWN = 0x00000080; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
35 const R = 0x00000100; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
36 const L = 0x00000200; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
37 const X = 0x00000400; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
38 const Y = 0x00000800; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
39 // Nothing |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
40 // Nothing |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
41 const ZL = 0x00004000; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
42 const ZR = 0x00008000; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
43 // Nothing |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
44 // Nothing |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
45 // Nothing |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
46 // Nothing |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
47 const TOUCH = 0x00100000; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
48 // Nothing |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
49 // Nothing |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
50 // Nothing |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
51 const C_RIGHT = 0x01000000; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
52 const C_LEFT = 0x02000000; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
53 const C_UP = 0x04000000; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
54 const C_DOWN = 0x08000000; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
55 const CIRCLE_RIGHT = 0x10000000; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
56 const CIRCLE_LEFT = 0x20000000; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
57 const CIRCLE_UP = 0x40000000; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
58 const CIRCLE_DOWN = 0x80000000; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
59 } |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
60 } |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
61 |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
62 #[derive(Debug, Default)] |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
63 struct Event { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
64 buttons: Buttons, |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
65 pad: (i16, i16), |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
66 c_pad: (i16, i16), |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
67 touch: (u16, u16), |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
68 } |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
69 |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
70 pub fn run_server(address: &str) -> io::Result<()> { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
71 let mut state = match State::new() { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
72 Ok(state) => state, |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
73 Err(err) => { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
74 match err.kind() { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
75 ErrorKind::NotFound => { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
76 eprintln!("Couldn’t find /dev/uinput: {}", err); |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
77 eprintln!("Maybe you forgot to `modprobe uinput`?"); |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
78 } |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
79 ErrorKind::PermissionDenied => { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
80 eprintln!("Couldn’t open /dev/uinput for writing: {}", err); |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
81 eprintln!("Maybe you aren’t allowed to create input devices?"); |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
82 } |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
83 _ => eprintln!("Couldn’t open /dev/uinput for writing: {}", err), |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
84 } |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
85 std::process::exit(1); |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
86 } |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
87 }; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
88 |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
89 let socket = UdpSocket::bind(address)?; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
90 println!("Listening on {:?}", socket); |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
91 println!("Here is an example client: https://hg.linkmauve.fr/remote-gamepad"); |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
92 |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
93 let mut event: Event = Default::default(); |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
94 let mut last = Some((0., 0.)); |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
95 state.set_size((320, 240)); |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
96 loop { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
97 // TODO: Yolo-alignment. |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
98 let buf: &mut [u8; 16] = unsafe { std::mem::transmute(&mut event) }; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
99 let (amount, source) = socket.recv_from(buf)?; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
100 if amount != std::mem::size_of::<Event>() { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
101 eprintln!("Invalid data length: {}", amount); |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
102 continue; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
103 } |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
104 println!("{:?} from {:?}", event, source); |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
105 if event.buttons.contains(Buttons::A) { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
106 state.select_tool(Key::ButtonToolPen); |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
107 } else if event.buttons.contains(Buttons::B) { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
108 state.select_tool(Key::ButtonToolRubber); |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
109 } else if event.buttons.contains(Buttons::X) { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
110 state.select_tool(Key::ButtonToolBrush); |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
111 } else if event.buttons.contains(Buttons::Y) { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
112 state.select_tool(Key::ButtonToolPencil); |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
113 } else if event.buttons.contains(Buttons::SELECT) { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
114 state.select_tool(Key::ButtonToolAirbrush); |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
115 } |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
116 let (x, y) = event.touch; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
117 if event.buttons.contains(Buttons::TOUCH) { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
118 if let None = last { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
119 state.press(x as f64, y as f64)?; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
120 last = Some((x as f64, y as f64)); |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
121 continue; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
122 } |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
123 } else { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
124 if let Some((x, y)) = last { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
125 state.release(x, y)?; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
126 last = None; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
127 continue; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
128 } |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
129 } |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
130 state.motion(x as f64, y as f64)?; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
131 last = Some((x as f64, y as f64)); |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
132 } |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
133 } |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
134 |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
135 pub fn main(args: &[String]) { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
136 let address = if args.len() > 1 { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
137 args[1].clone() |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
138 } else { |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
139 String::from("0.0.0.0:16150") |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
140 }; |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
141 run_server(&address).unwrap(); |
adab13145994
Add support for remote clients.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
142 } |