/// <summary>
 /// Creates an instance of <see cref="SendToAllAction"></see> for output binding.
 /// </summary>
 /// <param name="data">Web PubSub message data.</param>
 /// <param name="dataType">Web PubSub message data type.</param>
 /// <param name="excluded">ConnectionIds to exclude.</param>
 /// <returns>An instance of <see cref="SendToAllAction"></see>.</returns>
 public static SendToAllAction CreateSendToAllAction(string data, WebPubSubDataType dataType = WebPubSubDataType.Text, IEnumerable <string> excluded = null)
 {
     return(new SendToAllAction
     {
         Data = BinaryData.FromString(data),
         DataType = dataType,
         Excluded = excluded?.ToList(),
     });
 }
Пример #2
0
 public static void Run(
     ILogger logger,
     [WebPubSubTrigger("hub", WebPubSubEventType.User, "message")] UserEventRequest request,
     string data,
     WebPubSubDataType dataType)
 {
     logger.LogInformation("Request from: {user}, data: {data}, dataType: {dataType}",
                           request.ConnectionContext.UserId, data, dataType);
 }
 /// <summary>
 /// Creates an instance of <see cref="SendToAllAction"></see> for output binding.
 /// </summary>
 /// <param name="data">Web PubSub message data.</param>
 /// <param name="dataType">Web PubSub message data type.</param>
 /// <param name="excluded">ConnectionIds to exclude.</param>
 /// <returns>An instance of <see cref="SendToAllAction"></see>.</returns>
 public static SendToAllAction CreateSendToAllAction(BinaryData data, WebPubSubDataType dataType, IEnumerable <string> excluded = null)
 {
     return(new SendToAllAction
     {
         Data = data,
         DataType = dataType,
         Excluded = excluded?.ToList(),
     });
 }
 private static bool IsValidMediaType(this string mediaType, out WebPubSubDataType dataType)
 {
     try
     {
         dataType = mediaType.GetDataType();
         return(true);
     }
     catch
     {
         dataType = WebPubSubDataType.Binary;
         return(false);
     }
 }
 /// <summary>
 /// Creates an instance of <see cref="SendToUserAction"></see> for output binding.
 /// </summary>
 /// <param name="userId">Target userId.</param>
 /// <param name="data">Message data.</param>
 /// <param name="dataType">Message data type.</param>
 /// <returns>An instance of <see cref="SendToUserAction"></see>.</returns>
 public static SendToUserAction CreateSendToUserAction(string userId, string data, WebPubSubDataType dataType = WebPubSubDataType.Text)
 {
     return(new SendToUserAction
     {
         UserId = userId,
         Data = BinaryData.FromString(data),
         DataType = dataType
     });
 }
 /// <summary>
 /// Creates an instance of <see cref="SendToUserAction"></see> for output binding.
 /// </summary>
 /// <param name="userId">Target userId.</param>
 /// <param name="data">Message data.</param>
 /// <param name="dataType">Message data type.</param>
 /// <returns>An instance of <see cref="SendToUserAction"></see>.</returns>
 public static SendToUserAction CreateSendToUserAction(string userId, BinaryData data, WebPubSubDataType dataType)
 {
     return(new SendToUserAction
     {
         UserId = userId,
         Data = data,
         DataType = dataType
     });
 }
 /// <summary>
 /// Creates an instance of <see cref="SendToConnectionAction"></see> for output binding.
 /// </summary>
 /// <param name="connectionId">Target connectionId.</param>
 /// <param name="data">Message data.</param>
 /// <param name="dataType">Message data type.</param>
 /// <returns>An instance of <see cref="SendToConnectionAction"></see>.</returns>
 public static SendToConnectionAction CreateSendToConnectionAction(string connectionId, string data, WebPubSubDataType dataType = WebPubSubDataType.Text)
 {
     return(new SendToConnectionAction
     {
         ConnectionId = connectionId,
         Data = BinaryData.FromString(data),
         DataType = dataType
     });
 }
 /// <summary>
 /// Creates an instance of <see cref="SendToConnectionAction"></see> for output binding.
 /// </summary>
 /// <param name="connectionId">Target connectionId.</param>
 /// <param name="data">Message data.</param>
 /// <param name="dataType">Message data type.</param>
 /// <returns>An instance of <see cref="SendToConnectionAction"></see>.</returns>
 public static SendToConnectionAction CreateSendToConnectionAction(string connectionId, BinaryData data, WebPubSubDataType dataType)
 {
     return(new SendToConnectionAction
     {
         ConnectionId = connectionId,
         Data = data,
         DataType = dataType
     });
 }
Пример #9
0
 /// <summary>
 /// Initialize an instance of MessageResponse.
 /// </summary>
 /// <param name="data">BinaryData type message.</param>
 /// <param name="dataType">Message data type.</param>
 public UserEventResponse(BinaryData data, WebPubSubDataType dataType)
     : this()
 {
     Data     = data;
     DataType = dataType;
 }
Пример #10
0
 /// <summary>
 /// Initialize an instance of MessageResponse.
 /// </summary>
 /// <param name="data">String type message.</param>
 /// <param name="dataType">Message data type. Default set to text.</param>
 public UserEventResponse(string data, WebPubSubDataType dataType = WebPubSubDataType.Text)
     : this(BinaryData.FromString(data), dataType)
 {
 }
Пример #11
0
 /// <summary>
 /// The user event request
 /// </summary>
 /// <param name="context"></param>
 /// <param name="data"></param>
 /// <param name="dataType"></param>
 public UserEventRequest(WebPubSubConnectionContext context, BinaryData data, WebPubSubDataType dataType)
     : base(context)
 {
     Data     = data;
     DataType = dataType;
 }
Пример #12
0
 /// <summary>
 /// Create <see cref="UserEventResponse"/>.
 /// </summary>
 /// <param name="data">BinaryData message to return caller.</param>
 /// <param name="dataType">Message <see cref="WebPubSubDataType"/>.</param>
 /// <returns>A message response to return caller.</returns>
 public UserEventResponse CreateResponse(BinaryData data, WebPubSubDataType dataType)
 {
     return(new UserEventResponse(data, dataType));
 }
Пример #13
0
 /// <summary>
 /// Create <see cref="UserEventResponse"/>.
 /// </summary>
 /// <param name="data">String message to return caller.</param>
 /// <param name="dataType">Message <see cref="WebPubSubDataType"/>, default as Text.</param>
 /// <returns>A message response to return caller.</returns>
 public UserEventResponse CreateResponse(string data, WebPubSubDataType dataType = WebPubSubDataType.Text)
 {
     return(new UserEventResponse(data, dataType));
 }
Пример #14
0
 public static void Func2([WebPubSubTrigger("testchat", WebPubSubEventType.User, "message")] WebPubSubConnectionContext connectionContext, BinaryData data, WebPubSubDataType dataType)
 {
 }
Пример #15
0
 public static MediaTypeHeaderValue GetMediaType(WebPubSubDataType dataType) => new(GetContentType(dataType));