I'm new to C# HubConnectionBuilder and websocket in general. One of its extension methods or overload I want to use is:
private HubConnection _connection;
....
....
_connection = new HubConnectionBuilder()
.WithUrl(uriString, HttpTransportType.WebSockets, actionHttpConnectionOptions).
.Build();
My purpose is to add some Headers into the _connection although I am not sure if I am doing it right but I want to add these headers.
Dictionary<string, string> httpHeaders = new Dictionary<string, string>()
{
{"Connection", "Upgrade"},
{"Upgrade", "websocket"},
{"Origin", "http://localhost:5256"},
{"Sec-WebSocket-Version", "13"},
{"Sec-WebSocket-Key", "dteldf73hdlzfg"},
};
I am having difficulty in the part of actionHttpConnectionOptions which has a signature Action<HttpConnectionOptions>.
How can I accomplish as I am not used in programming with Action or delegate?
P.S. My ultimate goal is to connect to a websocket server of AWS real-time transcription, so what I'm doing is a client. If I manually connect to the server using command line curl, it returns HTTP/1.1 101 Switching Protocols so that means handshaking
and everything has already established. If this everything goes okay with this, a microphone should be connected to the system to send voice messages to the websocket.