-
Notifications
You must be signed in to change notification settings - Fork 389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a serverless sample #39
Conversation
samples/Serverless/ClientHandler.cs
Outdated
_connection.On<string, string>("SendMessage", | ||
(string server, string message) => | ||
{ | ||
Console.WriteLine($"Received message from server {server}: {message}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add timestamp?
|
||
public async Task StartAsync() | ||
{ | ||
await _connection.StartAsync(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When will _connection
be disposed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the program terminate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should dispose it gracefully. We can pass in a cancellation token and request cancel once we read any input from command line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cancellation token in startasync seems no use for disposing connection, we can call DisposeAsync
explicitly after we get input
samples/Serverless/Serverless.csproj
Outdated
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="1.0.0" /> | ||
<PackageReference Include="Microsoft.Azure.SignalR" Version="1.0.0-preview1-10011" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use 1.0.0-*
to retrieve the latest version.
samples/Serverless/ClientHandler.cs
Outdated
@@ -0,0 +1,46 @@ | |||
// Copyright (c) .NET Foundation. All rights reserved. | |||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MIT
?
|
||
private void ShowHelp() | ||
{ | ||
Console.WriteLine("*********Usage*********\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using verbatim string.
Also the format can be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If using verbatim string the format will be a little weird because there must be no indent from the second line
samples/Serverless/README.md
Outdated
Azure SignalR Service Serverless Sample | ||
================================= | ||
|
||
This sample demonstrate a serverless Azure SignalR Service. One console app call REST API in service to send message and another console app work as a client to receive message through listening the service. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
->
This sample is a console app showing the use of Azure SignalR Service in server-less pattern. It provides two modes:
- Server Mode: use simple commands to call Azure SignalR Service REST API.
- Client Mode: connect to Azure SignalR Service and receive messages from server.
Also you can find how to generate an access token to authenticate with Azure SignalR Service.
samples/Serverless/Program.cs
Outdated
app.FullName = "Azure SignalR Serverless Sample"; | ||
app.HelpOption("--help"); | ||
|
||
var connectionString = app.Option("-c|--connectionstring", "Set ConnectionString", CommandOptionType.SingleValue, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow connection string to be set in user secrets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also need to support AzureConnectionString in appsetting.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can skip appsetting.json
.
### Start a client | ||
|
||
``` | ||
Serverless.exe client <ClientName> -c "<ConnectionString>" -h <HubName> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use dotnet run --no-build ...
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I've updated README
Add a serverless sample to demonstrate how to use service with rest api call and generate access token.