LiveCaptionTranslator/LiveCaptionTranslator/Models/IBMWatson/IBMWatsonSpeechToTextWebsocketService.cs
/// <summary>
/// Start Websocket connection and send start message.
/// </summary>
/// <returns></returns>
Start Websocket connection and send start message.
Start Websocket connection and send start message .
public async Task StartConnection()
        {
            Uri url;
            if (string.IsNullOrEmpty(Model))
            {
                url = new Uri(string.Format(BaseUrl, this.URL.Replace("https", "wss"), AccessToken));
            }
            else
            {
                url = new Uri(string.Format(BaseUrlWithModel, this.URL.Replace("https", "wss"), AccessToken, Model));
            }
            try
            {
                await ws.ConnectAsync(url, CancellationToken.None);
                await ws.SendAsync(OpenMessage, WebSocketMessageType.Text, true, CancellationToken.None);
                await HandleCallback();
                return;
            }
            catch (Exception)
            {
                throw;
            }
        }
public async Task StartConnection ( ) { Uri url ; if ( string . IsNullOrEmpty ( Model ) ) { url = new Uri ( string . Format ( BaseUrl , this . URL . Replace ( " " , " " ) , AccessToken ) ) ; } else { url = new Uri ( string . Format ( BaseUrlWithModel , this . URL . Replace ( " " , " " ) , AccessToken , Model ) ) ; } try { await ws . ConnectAsync ( url , CancellationToken . None ) ; await ws . SendAsync ( OpenMessage , WebSocketMessageType . Text , true , CancellationToken . None ) ; await HandleCallback ( ) ; return ; } catch ( Exception ) { throw ; } }
Start Websocket connection and send start message.
Start Websocket connection and send start message .
//url = new Uri(string.Format(BaseUrl, Region, AccessToken)); //url = new Uri(string.Format(BaseUrlWithModel, Region, AccessToken, Model));
None