lightstreamer_client/client_message_listener.rs
1/// Interface to be implemented to listen to `LightstreamerClient.sendMessage()` events reporting
2/// a message processing outcome. Events for these listeners are dispatched by a different
3/// thread than the one that generates them. All the notifications for a single `LightstreamerClient`,
4/// including notifications to `ClientListener`, `SubscriptionListener` and `ClientMessageListener`
5/// will be dispatched by the same thread. Only one event per message is fired on this listener.
6pub trait ClientMessageListener {
7 /// Event handler that is called by Lightstreamer when any notifications of the processing
8 /// outcome of the related message haven't been received yet and can no longer be received.
9 /// Typically, this happens after the session has been closed. In this case, the client has
10 /// no way of knowing the processing outcome and any outcome is possible.
11 ///
12 /// # Parameters
13 ///
14 /// * `msg`: the message to which this notification is related.
15 /// * `sent_on_network`: `true` if the message was sent on the network, `false` otherwise.
16 /// Even if the flag is `true`, it is not possible to infer whether the message actually
17 /// reached the Lightstreamer Server or not.
18 fn on_abort(&self, _msg: &str, _sent_on_network: bool) {
19 // Implementation for on_abort
20 unimplemented!("Implement on_abort method for ClientMessageListener.");
21 }
22
23 /// Event handler that is called by Lightstreamer when the related message has been processed
24 /// by the Server but the expected processing outcome could not be achieved for any reason.
25 ///
26 /// # Parameters
27 ///
28 /// * `msg`: the message to which this notification is related.
29 /// * `code`: the error code sent by the Server. It can be one of the following:
30 /// - `<= 0`: the Metadata Adapter has refused the message; the code value is dependent
31 /// on the specific Metadata Adapter implementation.
32 /// * `error`: the description of the error sent by the Server.
33 fn on_deny(&self, _msg: &str, _code: i32, _error: &str) {
34 // Implementation for on_deny
35 unimplemented!("Implement on_deny method for ClientMessageListener.");
36 }
37
38 /// Event handler that is called by Lightstreamer to notify that the related message has
39 /// been discarded by the Server. This means that the message has not reached the Metadata
40 /// Adapter and the message next in the sequence is considered enabled for processing.
41 ///
42 /// # Parameters
43 ///
44 /// * `msg`: the message to which this notification is related.
45 fn on_discarded(&self, _msg: &str) {
46 // Implementation for on_discarded
47 unimplemented!("Implement on_discarded method for ClientMessageListener.");
48 }
49
50 /// Event handler that is called by Lightstreamer when the related message has been processed
51 /// by the Server but the processing has failed for any reason. The level of completion of
52 /// the processing by the Metadata Adapter cannot be determined.
53 ///
54 /// # Parameters
55 ///
56 /// * `msg`: the message to which this notification is related.
57 fn on_error(&self, _msg: &str) {
58 // Implementation for on_error
59 unimplemented!("Implement on_error method for ClientMessageListener.");
60 }
61
62 /// Event handler that is called by Lightstreamer when the related message has been processed
63 /// by the Server with success.
64 ///
65 /// # Parameters
66 ///
67 /// * `msg`: the message to which this notification is related.
68 /// * `response`: the response from the Metadata Adapter. If not supplied (i.e. supplied as `None`),
69 /// an empty message is received here.
70 fn on_processed(&self, _msg: &str, _response: Option<&str>) {
71 // Implementation for on_processed
72 unimplemented!("Implement on_processed method for ClientMessageListener.");
73 }
74}