Skip to content

Instantly share code, notes, and snippets.

@xximjasonxx
Created May 2, 2020 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xximjasonxx/dbbfa1dd10b0035357b1f20de62da042 to your computer and use it in GitHub Desktop.
Save xximjasonxx/dbbfa1dd10b0035357b1f20de62da042 to your computer and use it in GitHub Desktop.
[FunctionName("NewDocumentNotify")]
public static async Task Run(
[CosmosDBTrigger(databaseName: "namesdata", collectionName: "firstletterstrend",
ConnectionStringSetting = "CosmosDbConnection",
CreateLeaseCollectionIfNotExists = true)]IReadOnlyList<Document> newDocuments,
[SignalR(HubName = "FirstNameLetterTrend")]IAsyncCollector<SignalRMessage> signalRMessage,
ILogger log)
{
log.LogInformation($"Sending {newDocuments.Count} documents");
await signalRMessage.AddAsync(new SignalRMessage
{
Target = "newFirstLetterData",
Arguments = newDocuments
.Select(doc => JsonConvert.DeserializeObject<AggregateLetterCountDocument>(doc.ToString()))
.ToArray()
});
}
[FunctionName("negotiate")]
public static SignalRConnectionInfo GetSignalRInfo(
[HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequest req,
[SignalRConnectionInfo(HubName = "FirstNameLetterTrend")] SignalRConnectionInfo connectionInfo)
{
return connectionInfo;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment