public async Task CloseSession(string username) { if (_sessions.ContainsKey(username)) { CardSavrHttpClient client = _sessions[username].client; await client.EndAsync(); _sessions.Remove(username); } }
public async Task <ClientSession> LoginAndCreateSession(string username, string password, string trace = null) { if (_sessions.ContainsKey(username)) { return(_sessions[username]); } CardSavrHttpClient session = new CardSavrHttpClient(_rejectUnauthorized); session.Setup(_cardsavrServer, _appKey, _appName, username, password, trace); CardSavrResponse <LoginResult> login = await session.Init(); _sessions[username] = new ClientSession { client = session }; return(_sessions[username]); }