pub struct SignalRMessage {
pub user_id: Option<String>,
pub group_name: Option<String>,
pub target: String,
pub arguments: Vec<Value>,
}
Expand description
Represents the SignalR message output binding.
The following binding attributes are supported:
Name | Description |
---|---|
name | The name of the parameter being bound. |
hub_name | The name of the SignalR hub that will receive the message. |
connection | The name of the app setting that contains the SignalR Service connection string. Defaults to AzureSignalRConnectionString . |
§Examples
This example implements an HTTP-triggered Azure Function that returns a SignalRMessage binding:
use azure_functions::{
bindings::{HttpRequest, SignalRMessage},
func,
};
use serde_json::{to_value, Value};
#[func]
#[binding(name = "req", auth_level = "anonymous", methods = "post")]
#[binding(name = "$return", hub_name = "chat", connection = "myconnection")]
pub fn send_message(req: HttpRequest) -> SignalRMessage {
SignalRMessage {
user_id: req.query_params().get("user").map(|v| v.to_owned()),
group_name: req.query_params().get("group").map(|v| v.to_owned()),
target: "newMessage".to_owned(),
arguments: vec![req.query_params().get("message").map_or(Value::Null, |v| to_value(v).unwrap())],
}
}
Fields§
§user_id: Option<String>
The optional user id to send the message to.
group_name: Option<String>
The optional group name to send the message to.
target: String
The target method name to invoke on each SignalR client.
arguments: Vec<Value>
The arguments to pass to the target method.
Trait Implementations§
Source§impl Clone for SignalRMessage
impl Clone for SignalRMessage
Source§fn clone(&self) -> SignalRMessage
fn clone(&self) -> SignalRMessage
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SignalRMessage
impl Debug for SignalRMessage
Source§impl<'de> Deserialize<'de> for SignalRMessage
impl<'de> Deserialize<'de> for SignalRMessage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SignalRMessage
impl RefUnwindSafe for SignalRMessage
impl Send for SignalRMessage
impl Sync for SignalRMessage
impl Unpin for SignalRMessage
impl UnwindSafe for SignalRMessage
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request