Let's carry out the following steps to create a function that sets up the SignalR client connection object:
- Open QuestionPage.tsx and import the following from the SignalR client:
import { HubConnectionBuilder, HubConnectionState, HubConnection,} from '@aspnet/signalr';
- 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 ...