Connect to API
Chess-api is not available to all hosts. If you want to connect to the api you must add your host to "AllowedHosts" in appsetings.json.
C# users
Required NuGet packages
Microsoft.AspNetCore.SignalR.Common
To create a new connection
private HubConnection GetHubConnection()
{
return new HubConnectionBuilder()
.WithUrl("https://chesswebapi20210509195304.azurewebsites.net/gamehub")
.Build();
}
To start the connection
private Task StartConnection()
{
connection = GetHubConnection();
return connection.StartAsync();
}
JavaScript users
Required npm packages
@microsoft/signalr
Before you start
Install required package - open terminal in the project directory and type "npm install @microsoft/signalr".
Include reference to signalr.js library in <script> element. For example:
<script src="~/lib/signalr/signalr.js"></script>
To create a new connection
const connection = new signalR.HubConnectionBuilder()
.withUrl("https://chesswebapi20210509195304.azurewebsites.net/gamehub")
.build();
To start the connection
await connection.start();
Last updated