Merge remote-tracking branch 'origin/master' into dev
This commit is contained in:
Коммит
a58bce2102
|
@ -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
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче