pub struct Server {
pub full_update: bool,
pub object_profiling: bool,
pub cursor_profiling: bool,
pub blob_profiling: bool,
/* private fields */
}
Expand description
TUIO Server which keeps track of all TUIO elements and which send TUIO messages over the network
Fields§
§full_update: bool
§object_profiling: bool
§cursor_profiling: bool
§blob_profiling: bool
Implementations§
Source§impl Server
impl Server
Sourcepub fn new(source_name: &str) -> Result<Self, Error>
pub fn new(source_name: &str) -> Result<Self, Error>
Creates a TUIO Server with a default UdpSender configured for 127.0.0.1:3333
§Arguments
source_name
- the source name
Examples found in repository?
examples/send_and_receive.rs (line 35)
31fn main() {
32 let client = Client::new().unwrap();
33 client.connect().expect("Client connecting");
34
35 let mut server = Server::new("server_name").unwrap();
36
37 server.init_frame();
38 let cursor_id = server.create_cursor(0., 0.);
39 let object_id = server.create_object(1, 0., 0., 0.);
40 let blob_id = server.create_blob(0., 0., 0., 0.1, 0.1, 0.01);
41 server.commit_frame();
42 std::thread::sleep(Duration::from_secs(1));
43
44 if let Ok(Some(events)) = client.refresh() {
45 process_events(events);
46 }
47
48 server.init_frame();
49 server.update_cursor(cursor_id, 1., 1.);
50 server.update_object(object_id, 1., 1., 90f32.to_radians());
51 server.update_blob(blob_id, 1., 1., 90f32.to_radians(), 0.2, 0.2, 0.04);
52 server.commit_frame();
53
54 std::thread::sleep(Duration::from_secs(1));
55
56 if let Ok(Some(events)) = client.refresh() {
57 process_events(events);
58 }
59
60 server.init_frame();
61 server.remove_cursor(cursor_id);
62 server.remove_object(object_id);
63 server.remove_blob(blob_id);
64 server.commit_frame();
65
66 std::thread::sleep(Duration::from_secs(1));
67
68 if let Ok(Some(events)) = client.refresh() {
69 process_events(events);
70 }
71}
Sourcepub fn from_socket_addr(socket_addr: SocketAddr) -> Result<Self, Error>
pub fn from_socket_addr(socket_addr: SocketAddr) -> Result<Self, Error>
Creates a TUIO Server with a UdpSender configured from a provided socket address
§Arguments
socket_addr
- a socket address SocketAddr
Sourcepub fn from_osc_sender(
osc_sender: impl SendOsc<OscPacket, OscError> + 'static,
) -> Self
pub fn from_osc_sender( osc_sender: impl SendOsc<OscPacket, OscError> + 'static, ) -> Self
Sourcepub fn add_osc_sender(
&mut self,
osc_sender: impl SendOsc<OscPacket, OscError> + 'static,
)
pub fn add_osc_sender( &mut self, osc_sender: impl SendOsc<OscPacket, OscError> + 'static, )
Adds an OSC sender implementing [OscSender] trait
§Arguments
osc_sender
- a sender implementing [OscSender]
Sourcepub fn set_source_name(&mut self, name: &str)
pub fn set_source_name(&mut self, name: &str)
Sets the server source name which is sent through the TUIO source message
§Arguments
name
- the name of the source
Sourcepub fn enable_periodic_message(&mut self, interval: Option<Duration>)
pub fn enable_periodic_message(&mut self, interval: Option<Duration>)
Sourcepub fn disable_periodic_message(&mut self)
pub fn disable_periodic_message(&mut self)
Sourcepub fn create_object(
&mut self,
class_id: i32,
x: f32,
y: f32,
angle: f32,
) -> i32
pub fn create_object( &mut self, class_id: i32, x: f32, y: f32, angle: f32, ) -> i32
Creates a TUIO Object and returns its session_id
§Arguments
class_id
- a unique identifier that can be associated with a tangible objectx
- the object’s x positiony
- the object’s y positionangle
- the object’s angle
Examples found in repository?
examples/send_and_receive.rs (line 39)
31fn main() {
32 let client = Client::new().unwrap();
33 client.connect().expect("Client connecting");
34
35 let mut server = Server::new("server_name").unwrap();
36
37 server.init_frame();
38 let cursor_id = server.create_cursor(0., 0.);
39 let object_id = server.create_object(1, 0., 0., 0.);
40 let blob_id = server.create_blob(0., 0., 0., 0.1, 0.1, 0.01);
41 server.commit_frame();
42 std::thread::sleep(Duration::from_secs(1));
43
44 if let Ok(Some(events)) = client.refresh() {
45 process_events(events);
46 }
47
48 server.init_frame();
49 server.update_cursor(cursor_id, 1., 1.);
50 server.update_object(object_id, 1., 1., 90f32.to_radians());
51 server.update_blob(blob_id, 1., 1., 90f32.to_radians(), 0.2, 0.2, 0.04);
52 server.commit_frame();
53
54 std::thread::sleep(Duration::from_secs(1));
55
56 if let Ok(Some(events)) = client.refresh() {
57 process_events(events);
58 }
59
60 server.init_frame();
61 server.remove_cursor(cursor_id);
62 server.remove_object(object_id);
63 server.remove_blob(blob_id);
64 server.commit_frame();
65
66 std::thread::sleep(Duration::from_secs(1));
67
68 if let Ok(Some(events)) = client.refresh() {
69 process_events(events);
70 }
71}
Sourcepub fn update_object(&mut self, session_id: i32, x: f32, y: f32, angle: f32)
pub fn update_object(&mut self, session_id: i32, x: f32, y: f32, angle: f32)
Updates a TUIO Object
§Arguments
session_id
- the object’s session idx
- the new object’s x positiony
- the new object’s y positionangle
- the new object’s angle
Examples found in repository?
examples/send_and_receive.rs (line 50)
31fn main() {
32 let client = Client::new().unwrap();
33 client.connect().expect("Client connecting");
34
35 let mut server = Server::new("server_name").unwrap();
36
37 server.init_frame();
38 let cursor_id = server.create_cursor(0., 0.);
39 let object_id = server.create_object(1, 0., 0., 0.);
40 let blob_id = server.create_blob(0., 0., 0., 0.1, 0.1, 0.01);
41 server.commit_frame();
42 std::thread::sleep(Duration::from_secs(1));
43
44 if let Ok(Some(events)) = client.refresh() {
45 process_events(events);
46 }
47
48 server.init_frame();
49 server.update_cursor(cursor_id, 1., 1.);
50 server.update_object(object_id, 1., 1., 90f32.to_radians());
51 server.update_blob(blob_id, 1., 1., 90f32.to_radians(), 0.2, 0.2, 0.04);
52 server.commit_frame();
53
54 std::thread::sleep(Duration::from_secs(1));
55
56 if let Ok(Some(events)) = client.refresh() {
57 process_events(events);
58 }
59
60 server.init_frame();
61 server.remove_cursor(cursor_id);
62 server.remove_object(object_id);
63 server.remove_blob(blob_id);
64 server.commit_frame();
65
66 std::thread::sleep(Duration::from_secs(1));
67
68 if let Ok(Some(events)) = client.refresh() {
69 process_events(events);
70 }
71}
Sourcepub fn remove_object(&mut self, session_id: i32)
pub fn remove_object(&mut self, session_id: i32)
Examples found in repository?
examples/send_and_receive.rs (line 62)
31fn main() {
32 let client = Client::new().unwrap();
33 client.connect().expect("Client connecting");
34
35 let mut server = Server::new("server_name").unwrap();
36
37 server.init_frame();
38 let cursor_id = server.create_cursor(0., 0.);
39 let object_id = server.create_object(1, 0., 0., 0.);
40 let blob_id = server.create_blob(0., 0., 0., 0.1, 0.1, 0.01);
41 server.commit_frame();
42 std::thread::sleep(Duration::from_secs(1));
43
44 if let Ok(Some(events)) = client.refresh() {
45 process_events(events);
46 }
47
48 server.init_frame();
49 server.update_cursor(cursor_id, 1., 1.);
50 server.update_object(object_id, 1., 1., 90f32.to_radians());
51 server.update_blob(blob_id, 1., 1., 90f32.to_radians(), 0.2, 0.2, 0.04);
52 server.commit_frame();
53
54 std::thread::sleep(Duration::from_secs(1));
55
56 if let Ok(Some(events)) = client.refresh() {
57 process_events(events);
58 }
59
60 server.init_frame();
61 server.remove_cursor(cursor_id);
62 server.remove_object(object_id);
63 server.remove_blob(blob_id);
64 server.commit_frame();
65
66 std::thread::sleep(Duration::from_secs(1));
67
68 if let Ok(Some(events)) = client.refresh() {
69 process_events(events);
70 }
71}
Sourcepub fn create_cursor(&mut self, x: f32, y: f32) -> i32
pub fn create_cursor(&mut self, x: f32, y: f32) -> i32
Creates a TUIO Cursor and returns its session_id
§Arguments
x
- the cursor’s x positiony
- the cursor’s y position
Examples found in repository?
examples/send_and_receive.rs (line 38)
31fn main() {
32 let client = Client::new().unwrap();
33 client.connect().expect("Client connecting");
34
35 let mut server = Server::new("server_name").unwrap();
36
37 server.init_frame();
38 let cursor_id = server.create_cursor(0., 0.);
39 let object_id = server.create_object(1, 0., 0., 0.);
40 let blob_id = server.create_blob(0., 0., 0., 0.1, 0.1, 0.01);
41 server.commit_frame();
42 std::thread::sleep(Duration::from_secs(1));
43
44 if let Ok(Some(events)) = client.refresh() {
45 process_events(events);
46 }
47
48 server.init_frame();
49 server.update_cursor(cursor_id, 1., 1.);
50 server.update_object(object_id, 1., 1., 90f32.to_radians());
51 server.update_blob(blob_id, 1., 1., 90f32.to_radians(), 0.2, 0.2, 0.04);
52 server.commit_frame();
53
54 std::thread::sleep(Duration::from_secs(1));
55
56 if let Ok(Some(events)) = client.refresh() {
57 process_events(events);
58 }
59
60 server.init_frame();
61 server.remove_cursor(cursor_id);
62 server.remove_object(object_id);
63 server.remove_blob(blob_id);
64 server.commit_frame();
65
66 std::thread::sleep(Duration::from_secs(1));
67
68 if let Ok(Some(events)) = client.refresh() {
69 process_events(events);
70 }
71}
Sourcepub fn update_cursor(&mut self, session_id: i32, x: f32, y: f32)
pub fn update_cursor(&mut self, session_id: i32, x: f32, y: f32)
Updates a TUIO Cursor
§Arguments
session_id
- the cursor’s session idx
- the new cursor’s x positiony
- the new cursor’s y position
Examples found in repository?
examples/send_and_receive.rs (line 49)
31fn main() {
32 let client = Client::new().unwrap();
33 client.connect().expect("Client connecting");
34
35 let mut server = Server::new("server_name").unwrap();
36
37 server.init_frame();
38 let cursor_id = server.create_cursor(0., 0.);
39 let object_id = server.create_object(1, 0., 0., 0.);
40 let blob_id = server.create_blob(0., 0., 0., 0.1, 0.1, 0.01);
41 server.commit_frame();
42 std::thread::sleep(Duration::from_secs(1));
43
44 if let Ok(Some(events)) = client.refresh() {
45 process_events(events);
46 }
47
48 server.init_frame();
49 server.update_cursor(cursor_id, 1., 1.);
50 server.update_object(object_id, 1., 1., 90f32.to_radians());
51 server.update_blob(blob_id, 1., 1., 90f32.to_radians(), 0.2, 0.2, 0.04);
52 server.commit_frame();
53
54 std::thread::sleep(Duration::from_secs(1));
55
56 if let Ok(Some(events)) = client.refresh() {
57 process_events(events);
58 }
59
60 server.init_frame();
61 server.remove_cursor(cursor_id);
62 server.remove_object(object_id);
63 server.remove_blob(blob_id);
64 server.commit_frame();
65
66 std::thread::sleep(Duration::from_secs(1));
67
68 if let Ok(Some(events)) = client.refresh() {
69 process_events(events);
70 }
71}
Sourcepub fn remove_cursor(&mut self, session_id: i32)
pub fn remove_cursor(&mut self, session_id: i32)
Examples found in repository?
examples/send_and_receive.rs (line 61)
31fn main() {
32 let client = Client::new().unwrap();
33 client.connect().expect("Client connecting");
34
35 let mut server = Server::new("server_name").unwrap();
36
37 server.init_frame();
38 let cursor_id = server.create_cursor(0., 0.);
39 let object_id = server.create_object(1, 0., 0., 0.);
40 let blob_id = server.create_blob(0., 0., 0., 0.1, 0.1, 0.01);
41 server.commit_frame();
42 std::thread::sleep(Duration::from_secs(1));
43
44 if let Ok(Some(events)) = client.refresh() {
45 process_events(events);
46 }
47
48 server.init_frame();
49 server.update_cursor(cursor_id, 1., 1.);
50 server.update_object(object_id, 1., 1., 90f32.to_radians());
51 server.update_blob(blob_id, 1., 1., 90f32.to_radians(), 0.2, 0.2, 0.04);
52 server.commit_frame();
53
54 std::thread::sleep(Duration::from_secs(1));
55
56 if let Ok(Some(events)) = client.refresh() {
57 process_events(events);
58 }
59
60 server.init_frame();
61 server.remove_cursor(cursor_id);
62 server.remove_object(object_id);
63 server.remove_blob(blob_id);
64 server.commit_frame();
65
66 std::thread::sleep(Duration::from_secs(1));
67
68 if let Ok(Some(events)) = client.refresh() {
69 process_events(events);
70 }
71}
Sourcepub fn create_blob(
&mut self,
x: f32,
y: f32,
angle: f32,
width: f32,
height: f32,
area: f32,
) -> i32
pub fn create_blob( &mut self, x: f32, y: f32, angle: f32, width: f32, height: f32, area: f32, ) -> i32
Creates a TUIO Blob and returns its session_id
§Arguments
x
- the blob’s x positiony
- the blob’s y positionangle
- the blob’s anglewidth
- the blob’s widthheight
- the blob’s heightarea
- the blob’s area
Examples found in repository?
examples/send_and_receive.rs (line 40)
31fn main() {
32 let client = Client::new().unwrap();
33 client.connect().expect("Client connecting");
34
35 let mut server = Server::new("server_name").unwrap();
36
37 server.init_frame();
38 let cursor_id = server.create_cursor(0., 0.);
39 let object_id = server.create_object(1, 0., 0., 0.);
40 let blob_id = server.create_blob(0., 0., 0., 0.1, 0.1, 0.01);
41 server.commit_frame();
42 std::thread::sleep(Duration::from_secs(1));
43
44 if let Ok(Some(events)) = client.refresh() {
45 process_events(events);
46 }
47
48 server.init_frame();
49 server.update_cursor(cursor_id, 1., 1.);
50 server.update_object(object_id, 1., 1., 90f32.to_radians());
51 server.update_blob(blob_id, 1., 1., 90f32.to_radians(), 0.2, 0.2, 0.04);
52 server.commit_frame();
53
54 std::thread::sleep(Duration::from_secs(1));
55
56 if let Ok(Some(events)) = client.refresh() {
57 process_events(events);
58 }
59
60 server.init_frame();
61 server.remove_cursor(cursor_id);
62 server.remove_object(object_id);
63 server.remove_blob(blob_id);
64 server.commit_frame();
65
66 std::thread::sleep(Duration::from_secs(1));
67
68 if let Ok(Some(events)) = client.refresh() {
69 process_events(events);
70 }
71}
Sourcepub fn update_blob(
&mut self,
session_id: i32,
x: f32,
y: f32,
angle: f32,
width: f32,
height: f32,
area: f32,
)
pub fn update_blob( &mut self, session_id: i32, x: f32, y: f32, angle: f32, width: f32, height: f32, area: f32, )
Updates a TUIO Blob
§Arguments
session_id
- the blob’s session idx
- the new blob’s x positiony
- the new blob’s y positionangle
- the new blob’s anglewidth
- the new blob’s widthheight
- the new blob’s heightarea
- the new blob’s area
Examples found in repository?
examples/send_and_receive.rs (line 51)
31fn main() {
32 let client = Client::new().unwrap();
33 client.connect().expect("Client connecting");
34
35 let mut server = Server::new("server_name").unwrap();
36
37 server.init_frame();
38 let cursor_id = server.create_cursor(0., 0.);
39 let object_id = server.create_object(1, 0., 0., 0.);
40 let blob_id = server.create_blob(0., 0., 0., 0.1, 0.1, 0.01);
41 server.commit_frame();
42 std::thread::sleep(Duration::from_secs(1));
43
44 if let Ok(Some(events)) = client.refresh() {
45 process_events(events);
46 }
47
48 server.init_frame();
49 server.update_cursor(cursor_id, 1., 1.);
50 server.update_object(object_id, 1., 1., 90f32.to_radians());
51 server.update_blob(blob_id, 1., 1., 90f32.to_radians(), 0.2, 0.2, 0.04);
52 server.commit_frame();
53
54 std::thread::sleep(Duration::from_secs(1));
55
56 if let Ok(Some(events)) = client.refresh() {
57 process_events(events);
58 }
59
60 server.init_frame();
61 server.remove_cursor(cursor_id);
62 server.remove_object(object_id);
63 server.remove_blob(blob_id);
64 server.commit_frame();
65
66 std::thread::sleep(Duration::from_secs(1));
67
68 if let Ok(Some(events)) = client.refresh() {
69 process_events(events);
70 }
71}
Sourcepub fn remove_blob(&mut self, session_id: i32)
pub fn remove_blob(&mut self, session_id: i32)
Examples found in repository?
examples/send_and_receive.rs (line 63)
31fn main() {
32 let client = Client::new().unwrap();
33 client.connect().expect("Client connecting");
34
35 let mut server = Server::new("server_name").unwrap();
36
37 server.init_frame();
38 let cursor_id = server.create_cursor(0., 0.);
39 let object_id = server.create_object(1, 0., 0., 0.);
40 let blob_id = server.create_blob(0., 0., 0., 0.1, 0.1, 0.01);
41 server.commit_frame();
42 std::thread::sleep(Duration::from_secs(1));
43
44 if let Ok(Some(events)) = client.refresh() {
45 process_events(events);
46 }
47
48 server.init_frame();
49 server.update_cursor(cursor_id, 1., 1.);
50 server.update_object(object_id, 1., 1., 90f32.to_radians());
51 server.update_blob(blob_id, 1., 1., 90f32.to_radians(), 0.2, 0.2, 0.04);
52 server.commit_frame();
53
54 std::thread::sleep(Duration::from_secs(1));
55
56 if let Ok(Some(events)) = client.refresh() {
57 process_events(events);
58 }
59
60 server.init_frame();
61 server.remove_cursor(cursor_id);
62 server.remove_object(object_id);
63 server.remove_blob(blob_id);
64 server.commit_frame();
65
66 std::thread::sleep(Duration::from_secs(1));
67
68 if let Ok(Some(events)) = client.refresh() {
69 process_events(events);
70 }
71}
Sourcepub fn init_frame(&mut self)
pub fn init_frame(&mut self)
Initializes a new frame.
Examples found in repository?
examples/send_and_receive.rs (line 37)
31fn main() {
32 let client = Client::new().unwrap();
33 client.connect().expect("Client connecting");
34
35 let mut server = Server::new("server_name").unwrap();
36
37 server.init_frame();
38 let cursor_id = server.create_cursor(0., 0.);
39 let object_id = server.create_object(1, 0., 0., 0.);
40 let blob_id = server.create_blob(0., 0., 0., 0.1, 0.1, 0.01);
41 server.commit_frame();
42 std::thread::sleep(Duration::from_secs(1));
43
44 if let Ok(Some(events)) = client.refresh() {
45 process_events(events);
46 }
47
48 server.init_frame();
49 server.update_cursor(cursor_id, 1., 1.);
50 server.update_object(object_id, 1., 1., 90f32.to_radians());
51 server.update_blob(blob_id, 1., 1., 90f32.to_radians(), 0.2, 0.2, 0.04);
52 server.commit_frame();
53
54 std::thread::sleep(Duration::from_secs(1));
55
56 if let Ok(Some(events)) = client.refresh() {
57 process_events(events);
58 }
59
60 server.init_frame();
61 server.remove_cursor(cursor_id);
62 server.remove_object(object_id);
63 server.remove_blob(blob_id);
64 server.commit_frame();
65
66 std::thread::sleep(Duration::from_secs(1));
67
68 if let Ok(Some(events)) = client.refresh() {
69 process_events(events);
70 }
71}
Sourcepub fn commit_frame(&mut self)
pub fn commit_frame(&mut self)
Commits the current frame.
Generates and sends TUIO messages of all currently active and updated Objects, Cursors and Blobs
Examples found in repository?
examples/send_and_receive.rs (line 41)
31fn main() {
32 let client = Client::new().unwrap();
33 client.connect().expect("Client connecting");
34
35 let mut server = Server::new("server_name").unwrap();
36
37 server.init_frame();
38 let cursor_id = server.create_cursor(0., 0.);
39 let object_id = server.create_object(1, 0., 0., 0.);
40 let blob_id = server.create_blob(0., 0., 0., 0.1, 0.1, 0.01);
41 server.commit_frame();
42 std::thread::sleep(Duration::from_secs(1));
43
44 if let Ok(Some(events)) = client.refresh() {
45 process_events(events);
46 }
47
48 server.init_frame();
49 server.update_cursor(cursor_id, 1., 1.);
50 server.update_object(object_id, 1., 1., 90f32.to_radians());
51 server.update_blob(blob_id, 1., 1., 90f32.to_radians(), 0.2, 0.2, 0.04);
52 server.commit_frame();
53
54 std::thread::sleep(Duration::from_secs(1));
55
56 if let Ok(Some(events)) = client.refresh() {
57 process_events(events);
58 }
59
60 server.init_frame();
61 server.remove_cursor(cursor_id);
62 server.remove_object(object_id);
63 server.remove_blob(blob_id);
64 server.commit_frame();
65
66 std::thread::sleep(Duration::from_secs(1));
67
68 if let Ok(Some(events)) = client.refresh() {
69 process_events(events);
70 }
71}
pub fn send_full_messages(&self)
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Server
impl !RefUnwindSafe for Server
impl !Send for Server
impl !Sync for Server
impl Unpin for Server
impl !UnwindSafe for Server
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more