예제 #1
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            TraceWriter log)
        {
            var    signalR = new AzureSignalR(Environment.GetEnvironmentVariable("AzureSignalRConnectionString"));
            string name    = req.Query["name"];
            string message = req.Query["message"];

            // broadcast through SignalR
            await signalR.SendAsync(HubName, "broadcastMessage", name, message);

            return(new OkObjectResult($"OK"));
        }
예제 #2
0
 public static IActionResult Run(
     [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequestMessage req,
     TraceWriter log)
 {
     try {
         var signalR = new AzureSignalR(Environment.GetEnvironmentVariable("AzureSignalRConnectionString"));
         return(new OkObjectResult(new {
             authInfo = new {
                 serviceUrl = signalR.GetClientHubUrl(HubName),
                 accessToken = signalR.GenerateAccessToken(HubName)
             }
         }
                                   ));
     } catch (Exception ex) {
         log.Error(ex.Message);
         log.Error(ex.StackTrace);
         throw;
     }
 }