Merge remote-tracking branch 'origin/master' into dev

This commit is contained in:
Zitong Yang 2021-03-02 14:50:33 +08:00
Родитель bb6f714e0e 30a08f2d96
Коммит a58bce2102
5 изменённых файлов: 19 добавлений и 14 удалений

Просмотреть файл

@ -103,14 +103,7 @@ It's a quick try of this sample. You will create an Azure SignalR Service and an
5. Click **Save** to persist the CORS settings.
![CORS](cors.png)
2. Install [Live Server](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer) for your VS Code, that can serve web pages locally
3. Open `bidirectional-chat/content/index.html` and edit base url
2. `<function-app-url>/api/index` hosts the web page for the demo
```js
window.apiBaseUrl = '<function-app-url>';
```
4. With **index.html** open, start Live Server by opening the VS Code command palette (**F1**) and selecting **Live Server: Open with Live Server**. Live Server will open the application in a browser.
5. Try send messages by entering them into the main chat box.
3. Try send messages by entering them into the main chat box.
![Chatroom](chatroom.png)

Просмотреть файл

@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.Azure.WebJobs.Extensions.SignalRService;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Mvc;
namespace FunctionApp
{
@ -15,6 +16,16 @@ namespace FunctionApp
private const string NewMessageTarget = "newMessage";
private const string NewConnectionTarget = "newConnection";
[FunctionName("index")]
public IActionResult GetHomePage([HttpTrigger(AuthorizationLevel.Anonymous)]HttpRequest req)
{
return new ContentResult
{
Content = File.ReadAllText("content/index.html"),
ContentType = "text/html",
};
}
[FunctionName("negotiate")]
public SignalRConnectionInfo Negotiate([HttpTrigger(AuthorizationLevel.Anonymous)]HttpRequest req)
{

Просмотреть файл

@ -4,7 +4,7 @@
<title>Serverless Chat</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.1.3/dist/css/bootstrap.min.css">
<script>
window.apiBaseUrl = 'http://localhost:7071';
window.apiBaseUrl = window.location.origin;
</script>
<style>
.slide-fade-enter-active,
@ -145,7 +145,7 @@
}
}
});
const apiBaseUrl = prompt('Enter the Azure Function app base URL', window.apiBaseUrl);
const apiBaseUrl = window.apiBaseUrl; //prompt('Enter the Azure Function app base URL', window.apiBaseUrl);
data.username = prompt("Enter your username");
const isAdmin = confirm('Work as administrator? (only an administrator can broadcast messages)');
if (!data.username) {

Просмотреть файл

@ -11,6 +11,9 @@
<ProjectReference Include="..\..\..\src\SignalRServiceExtension\Microsoft.Azure.WebJobs.Extensions.SignalRService.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="content/index.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

Просмотреть файл

@ -8,8 +8,6 @@
"AzureSignalRServiceTransportType": "Transient"
},
"Host": {
"LocalHttpPort": 7071,
"CORS": "http://localhost:5500",
"CORSCredentials": true
"LocalHttpPort": 7071
}
}