Struct Server

Source
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

Enables the full update of all currently active and inactive Objects, Cursors and Blobs

§object_profiling: bool§cursor_profiling: bool§blob_profiling: bool

Implementations§

Source§

impl Server

Source

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}
Source

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
Source

pub fn from_osc_sender( osc_sender: impl SendOsc<OscPacket, OscError> + 'static, ) -> Self

Creates a TUIO Server from an OSC sender implementing [OscSender] trait

§Arguments
  • osc_sender - a sender implementing [OscSender]
Source

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]
Source

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
Source

pub fn enable_periodic_message(&mut self, interval: Option<Duration>)

Enables the periodic full update of all currently active TUIO Objects, Cursors and Blobs

§Arguments
  • interval - an option of a duration. Notes that the minimum interval will always be 10 milliseconds
Source

pub fn disable_periodic_message(&mut self)

Disable the periodic full update of all currently active TUIO Objects, Cursors and Blobs

Source

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 object
  • x - the object’s x position
  • y - the object’s y position
  • angle - 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}
Source

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 id
  • x - the new object’s x position
  • y - the new object’s y position
  • angle - 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}
Source

pub fn remove_object(&mut self, session_id: i32)

Removes a TUIO Object

§Arguments
  • session_id - the object’s session id
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}
Source

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 position
  • y - 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}
Source

pub fn update_cursor(&mut self, session_id: i32, x: f32, y: f32)

Updates a TUIO Cursor

§Arguments
  • session_id - the cursor’s session id
  • x - the new cursor’s x position
  • y - 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}
Source

pub fn remove_cursor(&mut self, session_id: i32)

Removes a TUIO Cursor

§Arguments
  • session_id - the cursor’s session id
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}
Source

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 position
  • y - the blob’s y position
  • angle - the blob’s angle
  • width - the blob’s width
  • height - the blob’s height
  • area - 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}
Source

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 id
  • x - the new blob’s x position
  • y - the new blob’s y position
  • angle - the new blob’s angle
  • width - the new blob’s width
  • height - the new blob’s height
  • area - 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}
Source

pub fn remove_blob(&mut self, session_id: i32)

Removes a TUIO Blob

§Arguments
  • session_id - the blob’s session id
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}
Source

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}
Source

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}
Source

pub fn send_full_messages(&self)

Trait Implementations§

Source§

impl Drop for Server

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.