public void AddSocket(WebSocket socket, Action <string, string[]> processTranscripts)
        {
            var socketId = CreateConnectionId();

            _sockets.TryAdd(socketId, socket);

            GoogleSpeechFactory.CreateSession(socketId, new GoogleSessionConfig(), processTranscripts);
        }
        public async Task RemoveSocket(string id)
        {
            WebSocket socket;

            _sockets.TryRemove(id, out socket);
            GoogleSpeechFactory.CloseSession(id);

            await socket.CloseAsync(closeStatus : WebSocketCloseStatus.NormalClosure,
                                    statusDescription : "Closed by the WebSocketManager",
                                    cancellationToken : CancellationToken.None);
        }
        public override async Task ReceiveAsyncData(WebSocket socket, WebSocketReceiveResult result, byte[] buffer)
        {
            try
            {
                var socketId = WebSocketConnectionManager.GetId(socket);

                //_log.Debug($"Socket ReceiveAsyncData:{result.Count}-{buffer.Length}");
                //_log.Debug($"Socket ReceiveAsyncData:{Convert.ToBase64String(buffer,0,result.Count)}");
                await GoogleSpeechFactory.SendAudio(socketId, new ArraySegment <byte>(buffer, 0, result.Count).Array);
            }
            catch (Exception e)
            {
                _log.Error($"Socket ReceiveAsyncData:{e.Message}", e);
            }
        }