Setting up the client connection

Let's carry out the following steps to create a function that sets up the SignalR client connection object:

  1. Open QuestionPage.tsx and import the following from the SignalR client:
import {  HubConnectionBuilder,  HubConnectionState,  HubConnection,} from '@aspnet/signalr';
  1. We're going to create a function to set up the SignalR connection in the QuestionPage component, just below where the question state is declared:
const [question, setQuestion] = useState<QuestionData | null>(null);const setUpSignalRConnection = async (questionId: number) => {  // TODO - setup connection to real-time SignalR API  // TODO - handle Message function being called   // TODO - handle ReceiveQuestion function being called  // TODO ...

Get ASP.NET Core 3 and React now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.