261001_03_ENH: 페이지 이탈(bfcache) 시 CTI 로그아웃 및 복귀 시 재로그인
This commit is contained in:
@@ -688,9 +688,36 @@ const connectAndLogin = (params: CtiLoginParams) => {
|
||||
openSocketAndLogin(params);
|
||||
};
|
||||
|
||||
// bfcache 진입 직전(pagehide, persisted): 열려 있는 소켓으로 Logout을 보내고 소켓만 정리한다.
|
||||
// 로그인 정보는 복귀(pageshow) 시 다시 로그인하기 위해 유지한다.
|
||||
// 통화 중이면 통화 처리가 꼬이지 않도록 Logout은 생략한다.
|
||||
const suspendForPageHide = () => {
|
||||
if (!currentLoginParams) return;
|
||||
stopReconnectLoop();
|
||||
if (currentAgentLoginId && connectionState === "open") {
|
||||
if (isCallInProgress()) {
|
||||
console.log("[CTI][TEMP_LOG] pagehide logout skipped, call is in progress"); // TEMP_CTI_LOG
|
||||
} else {
|
||||
send({ ZCommand: "Logout", AgentLoginID: currentAgentLoginId });
|
||||
}
|
||||
}
|
||||
teardownSocket();
|
||||
};
|
||||
|
||||
// bfcache 복귀(pageshow, persisted): 유지해 둔 로그인 정보로 다시 연결해 로그인한다.
|
||||
const resumeFromPageShow = () => {
|
||||
const params = currentLoginParams;
|
||||
if (!params) return;
|
||||
if (connectionState === "open" || connectionState === "connecting") return;
|
||||
console.log("[CTI][TEMP_LOG] pageshow resume, reconnecting"); // TEMP_CTI_LOG
|
||||
connectAndLogin(params);
|
||||
};
|
||||
|
||||
export const ctiClient = {
|
||||
connectAndLogin,
|
||||
logout,
|
||||
suspendForPageHide,
|
||||
resumeFromPageShow,
|
||||
subscribe: (listener: () => void) => {
|
||||
listeners.add(listener);
|
||||
return () => listeners.delete(listener);
|
||||
|
||||
Reference in New Issue
Block a user