Skip to content
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

Merged
merged 20 commits into from
Jul 13, 2018
Merged

Add a serverless sample #39

merged 20 commits into from
Jul 13, 2018

Conversation

zackliu
Copy link
Contributor

@zackliu zackliu commented Jul 6, 2018

Add a serverless sample to demonstrate how to use service with rest api call and generate access token.

_connection.On<string, string>("SendMessage",
(string server, string message) =>
{
Console.WriteLine($"Received message from server {server}: {message}");
Copy link
Contributor

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();
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the program terminate.

Copy link
Contributor

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.

Copy link
Contributor Author

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


<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="1.0.0" />
<PackageReference Include="Microsoft.Azure.SignalR" Version="1.0.0-preview1-10011" />
Copy link
Contributor

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.

@@ -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.
Copy link
Contributor

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" +
Copy link
Contributor

@xscript xscript Jul 12, 2018

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.

Copy link
Contributor Author

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

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.
Copy link
Contributor

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.

app.FullName = "Azure SignalR Serverless Sample";
app.HelpOption("--help");

var connectionString = app.Option("-c|--connectionstring", "Set ConnectionString", CommandOptionType.SingleValue, true);
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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>
Copy link
Contributor

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 ...?

Copy link
Contributor Author

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

@zackliu zackliu merged commit 833327f into aspnet:master Jul 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants