コード例 #1
0
 /// <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);
 }
コード例 #3
0
 /// <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(),
     });
 }
コード例 #4
0
 private static bool IsValidMediaType(this string mediaType, out WebPubSubDataType dataType)
 {
     try
     {
         dataType = mediaType.GetDataType();
         return(true);
     }
     catch
     {
         dataType = WebPubSubDataType.Binary;
         return(false);
     }
 }
コード例 #5
0
 /// <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
     });
 }
コード例 #6
0
 /// <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
     });
 }
コード例 #7
0
 /// <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
     });
 }
コード例 #8
0
 /// <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));