Appendix - GiGAGenie-ServiceSDK/UserGuide GitHub Wiki

μ›Ή μ†ŒμΌ“ 이용 방법

각 ν΄λΌμ΄μ–ΈνŠΈλŠ” λΆ„μ‚°λœ Node processμ—μ„œ μ ‘μ†ν•˜λ”λΌλ„ κ³΅ν†΅λœ μ„Έμ…˜μ„ κ³΅μœ ν•˜μ—¬ 데이터λ₯Ό 솑/μˆ˜μ‹  ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

6.1.1

  • μ›Ή μ†ŒμΌ“ μ„œλ²„ 정보 (SSL만 이용 κ°€λŠ₯)
    • wss://svcapp.gigagenie.ai/channel
  • WebSocket API Payload (μ˜ˆμ•½μ–΄)
    • msgtype : λ©”μ‹œμ§€ 솑/μˆ˜μ‹  μœ ν˜•
        β‘  request: μ„œλΉ„μŠ€ ν΄λΌμ΄μ–ΈνŠΈμ—μ„œμ˜ μš”μ²­, trxidλ₯Ό μ„€μ •ν•΄μ„œ νŠΈλžœμž­μ…˜μ„ ꡬ뢄해야함
        β‘‘ reply: request에 λŒ€ν•œ μ„œλ²„μ—μ„œμ˜ 처리 κ²°κ³Ό 전달, trxid둜 transaction ꡬ별
        β‘’ notify: μ„œλ²„μ—μ„œ ν΄λΌμ΄μ–ΈνŠΈλ‘œ μ „λ‹¬λ˜λŠ” event μ•Œλ¦Ό, trxid μ—†μŒ
        β‘£ data: Data 전달, trxid μ—†μŒ, 데이터 전달 채널 정보(TBD)
    • operation : 인증, μ„Έμ…˜ 생성/μ†Œλ©Έ, νŠΉμ • 데이터 전달 λ“±μ˜ μž‘μ—… κ΅¬λΆ„μž
        β‘  auth: 인증, μ„œλ²„μ— ν΄λΌμ΄μ–ΈνŠΈκ°€ 인증 μš”μ²­ μ‹œ μ‚¬μš©
        β‘‘ iam: 인증, μ„œλ²„μ—μ„œ WebSocket μ ‘μ†ν•œ ν΄λΌμ΄μ–ΈνŠΈμ— notifyν•  λ•Œ μ‚¬μš©
        β‘’ create_session: 채널 μ„Έμ…˜ 생성
        β‘£ join_session: μƒμ„±λœ 채널 μ„Έμ…˜μ— μ°Έμ—¬
        β‘€ ras_alive: WebSocket μ—°κ²° μœ μ§€λ₯Ό μœ„ν•œ PING-PONGμ‹œ μ‚¬μš©
        β‘₯ destroy_session: μƒμ„±λœ 채널 μ„Έμ…˜μ„ μ’…λ£Œ
        ⑦ set_input_history: ν…ŒμŠ€νŠΈλ₯Ό μœ„ν•œ μž…λ ₯된 URL μ €μž₯(UUIDκΈ°μ€€, 개발자 지원)
        ⑧ get_input_history: ν…ŒμŠ€νŠΈλ₯Ό μœ„ν•œ μž…λ ₯된 URL 쑰회(UUID κΈ°μ€€, 개발자 지원)
        ⑨ set_appid_devmode: ν•΄λ‹Ή APP_ID의 개발자λͺ¨λ“œ μ„€μ •
        β‘© check_appid_devmod: ν•΄λ‹Ή APP_IDκ°€ 개발자λͺ¨λ“œλ‘œ μ„€μ •λ˜μžˆλŠ”μ§€ 확인
        β‘ͺ confirm_appid_devmode: ν•΄λ‹Ή APP_IDλ₯Ό 개발자λͺ¨λ“œλ‘œ μ„€μ •(개발자 μ„Όν„°μš©, REST API둜 λŒ€μ²΄ κ°€λŠ₯)
    • channeltype: μ›Ή μ†ŒμΌ“ μ±„λ„μ˜ μš©λ„ κ΅¬λΆ„μž
        β‘  rtcaudio: WebRTC μ˜€λ””μ˜€ 채널 μœ ν˜•
        β‘‘ system: μ„œλ²„μ—μ„œ λ°œμƒν•˜λŠ” notifyλ₯Ό μ „λ‹¬ν•˜λŠ” 채널 μœ ν˜• (예, ras_alive)

μ—°κ²° (Connection)

WebSocket Protocol은 μ„œλΉ„μŠ€μ— 따라 μž„μ˜λ‘œ μ§€μ •ν•˜μ—¬ μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

  • WebSocket Protocolν‘œμ€€ μ€€μˆ˜(Header: Sec-WebSocket-Protocol)
  • μ—°κ²°μ˜ˆμ‹œ) [β€œwss://svcapp.gigagenie.ai/channel”, β€œws-channel-v1”]

인증 (AUTH)

6.3.1

    β‘  졜초 Client λŠ” μ„œλ²„μ— WebSocket connect λ₯Ό μ‹œλ„ν•©λ‹ˆλ‹€.
    β‘‘ μ„œλ²„λŠ” μ ‘μ†ν•œ ν΄λΌμ΄μ–ΈνŠΈμ— 인증이 ν•„μš”ν•¨μ„ μ•Œλ¦½λ‹ˆλ‹€.
    • Message sample :
      
      {
          "msgtype":"notify",
          "operation":"iam",
          "channeltype":"system"
      }
      
    • Client μ—μ„œμ˜ μˆ˜μ‹  μ²˜λ¦¬λŠ” μ•„λž˜μ˜ WebSocket ν΄λΌμ΄μ–ΈνŠΈ μƒ˜ν”Œ μ†ŒμŠ€ μ°Έκ³ .

    β‘’ Client λŠ” 인증 Request λ₯Ό 톡해 인증을 μš”μ²­ν•©λ‹ˆλ‹€.

    • Message sample :
      
      {
          "msgtype":"request",
          "operation":"auth",
          "uuid":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
          "channeltype":"webrtcaudio"
      }
      
    • Client μ—μ„œ Request μ²˜λ¦¬λŠ” μ•„λž˜μ˜ WebSocket ν΄λΌμ΄μ–ΈνŠΈ μƒ˜ν”Œ μ†ŒμŠ€ μ°Έκ³ .

    β‘£ μ„œλ²„μ‚¬μ΄λ“œμ—μ„œλŠ” λ‚΄λΆ€ 인증 연동을 ν†΅ν•˜μ—¬ κ·Έ κ²°κ³Όλ₯Ό reply ν•©λ‹ˆλ‹€.

    • Message sample :
      
      {
          "msgtype":"reply",
          "operation":"auth",
          "channeltype":"system",
          "result_cd":200,
          "result_msg":"authorized"
      }
      
    • Client μ—μ„œ Reply μ²˜λ¦¬λŠ” μ•„λž˜μ˜ WebSocket ν΄λΌμ΄μ–ΈνŠΈ μƒ˜ν”Œ μ†ŒμŠ€ μ°Έκ³ .

    β‘€ 인증에 μ„±κ³΅ν•˜λ©΄ 접속은 μœ μ§€λ˜κ³ , 톡신을 ν•  수 μžˆλŠ” μƒνƒœκ°€ λ©λ‹ˆλ‹€.
    β‘₯ λ§Œμ•½, μΌμ •μ‹œκ°„ Client κ°€ 인증에 μ‘ν•˜μ§€ μ•ŠμœΌλ©΄ 접속은 μžλ™ μ’…λ£Œλ©λ‹ˆλ‹€.

    
    socket.onmessage = function(message) {
        console.log('Socket server message', message.data);
        document.getElementById('response').innerHTML = message.data;
        let pdata = JSON.parse(message.data);
        console.log(pdata);
        if (pdata.msgtype === 'notify') {
            if (pdata.operation === 'iam') {
                var auth_message = {
                    "msgtype": "request",
                    "operation": "auth",
                    "uuid": uuid,
                    "channeltype": "webrtcaudio",
                };
                socket.send(JSON.stringify(auth_message));
                console.log('auth message sent.');
            }
            if (pdata.operation !== 'ras_alive') {;
            }
        } else if (pdata.msgtype === 'reply') {
            // authorized
            if (pdata.operation == 'auth') {
                if (pdata.result_cd == 200) {
                    var create_session = {
                        "msgtype": "request",
                        "operation": "create_session",
                        "channeltype": "webrtcaudio",
                        "uuid": uuid,
                        "trxid": "K0000000:1501463079077:00002"
                    };
                    socket.send(JSON.stringify(create_session));
                    console.log('create_session message sent.');
                } else {;
                }
            }
        } else if (pdata.msgtype === 'data') {;
        }
    };
    

μ ‘μ†μœ μ§€ (Alive test)

6.4.1

GATE-API Channel μ„œλ²„λŠ” μ ‘μ†ν•œ ν΄λΌμ΄μ–ΈνŠΈκ°€ μΌμ •ν•œ μ‹œκ°„ 이내에 Alive λ©”μ‹œμ§€λ₯Ό λ°œμ†‘ν•˜μ§€ μ•ŠμœΌλ©΄ 접속을 κ°•μ œλ‘œ μ’…λ£Œν•©λ‹ˆλ‹€.

  • Message sample :
    
    {
        "msgtype":"notify",
        "operation":"ras_alive",
        "channeltype":"system"
    }
    
  • Client μ—μ„œ alive μ²˜λ¦¬λŠ” λ‹€μŒμ˜ WebSocket ν΄λΌμ΄μ–ΈνŠΈ μƒ˜ν”Œ μ†ŒμŠ€ μ°Έκ³ .
  • 
    let ticker = 0;
    setInterval(function() {
        ticker++;
        if (ticker % 30 === 7) {
            console.log('@ras-alive:' + ticker);
            var alive_session = {
                "msgtype": "notify",
                "operation": "ras_alive",
                "channeltype": "system"
            };
            socket.send(JSON.stringify(alive_session));
        }
    }, 1000);
    
    λ³Έ 과정은 Dead connection 을 μ²˜λ¦¬ν•˜κΈ° μœ„ν•œ ν•˜λ‚˜μ˜ 절차둜 ν˜„μž¬ λ²„μ „μ—μ„œλŠ” ν•˜κΈ°μ˜ 쑰건으둜 μ²˜λ¦¬ν•©λ‹ˆλ‹€.
    • μ„œλ²„ 접속 μ’…λ£Œ μ‹œκ°„: 70 seconds
    • ν΄λΌμ΄μ–ΈνŠΈ ꢌμž₯ μ£ΌκΈ°: 30 ~ 60 seconds

Session 생성 μš”μ²­ (request, create_session)

6.5.1

Session 생성을 μš”μ²­ν•©λ‹ˆλ‹€. Session idλŠ” 기본적으둜 μ„œλ²„μ—μ„œ μƒμ„±ν•˜λ©°, Session id λ₯Ό μ§€μ •ν•˜λ©΄ μ§€μ •λœ μ΄λ¦„μœΌλ‘œ μƒμ„±ν•©λ‹ˆλ‹€.

  • Default session id 의 message sample:
    
    {
        "msgtype":"request",
       "operation":"create_session",
       "channeltype":"webrtcaudio",
       "uuid":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
       "trxid":"K0000000:1501463079077:00002"
    }
    
  • Specific session id 의 message sample:
    
    {
        "msgtype":"request",
        "operation":"create_session",
        "channeltype":"webrtcaudio",
        "sessionid":"abcd", 
        "uuid":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
        "trxid":"K0000000:1501463079077:00002"
    }
    
  • Client μ—μ„œ 상기 create_sessionκΉŒμ§€μ˜ 일련의 과정은 WebSocket ν΄λΌμ΄μ–ΈνŠΈ μƒ˜ν”Œ μ†ŒμŠ€ μ°Έκ³ .
β€» ν΄λΌμ΄μ–ΈνŠΈλŠ” 주기적으둜 alive λ©”μ‹œμ§€λ₯Ό λ°œμ†‘ν•΄μ•Ό 접속을 μœ μ§€ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

Session μž…μž₯ μš”μ²­ (request, join_session)

6.6.1

Session μž…μž₯을 μš”μ²­ν•©λ‹ˆλ‹€.
주의) μƒˆλ‘œμš΄ Client λŠ” 초기 인증과정을 μ²˜λ¦¬ν•΄μ•Όλ§Œ ν•©λ‹ˆλ‹€.

    β‘  Request join 을 μš”μ²­ν•©λ‹ˆλ‹€.
    • Message sample:
      
      {
          "msgtype":"request",
          "operation":"join_session",
          "channeltype":"webrtcaudio",
          "sessionid":"aaaa",
          "uuid":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
          "trxid":"K0000000:1501463079077:00002"
      }
      
    β‘‘ Request join 에 λŒ€ν•œ Reply μ²˜λ¦¬κ°€ λ©λ‹ˆλ‹€.
    • Message sample:
      
      {
          "msgtype":"reply",
          "operation":"join_session",
          "result_cd":200,
          "result_msg":"Success",
          "trxid":"K0000000:1501463079077:00002"
      }
      
    β‘’ μž…μž₯이 되면 ν•΄λ‹Ή Channel 에 Notify join_session 이 λ°œμƒν•©λ‹ˆλ‹€.
    • Message sample:
      
      {
          "msgtype":"notify",
          "operation":"join_session",
          "sessionid":"aaaa",
          "channeltype":"webrtcaudio"
      }
      

Session μ’…λ£Œ μš”μ²­ (request, destroy_session)

Session μ’…λ£Œμ„ μš”μ²­ν•©λ‹ˆλ‹€.
    β‘  Request destory 을 μš”μ²­ν•©λ‹ˆλ‹€.
    • Message sample:
      
      {
          "msgtype":"request",
          "operation":"destroy_session",
          "channeltype":"webrtcaudio",
          "sessionid":"aaaa",
          "uuid":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
          "trxid":"K0000000:1501463079077:00003"
      }
      
    β‘‘ Request join 에 λŒ€ν•œ Reply μ²˜λ¦¬κ°€ λ©λ‹ˆλ‹€.
    • Message sample:
      
      {
          "msgtype":"reply",
          "operation":"destroy_session",
          "result_cd":200,
          "result_msg":"Success",
          "trxid":"K0000000:1501463079077:00003"
      }
      
    β‘’ μž…μž₯이되면 ν•΄λ‹Ή Channel 에 Notify destroy_session 이 λ°œμƒν•©λ‹ˆλ‹€.
    • Message sample:
      
      {
          "msgtype":"notify",
          "operation":"destroy_session",
          "sessionid":"aaaa",
          "channeltype":"rtcaudio"
      }
      

Data 전솑 (Data)

6.8.1

OTV WebApp Message μ •μ˜

κΈ°λŠ₯ Message λ°œν™”νŒ¨ν„΄ μ˜ˆμ‹œ
μ΄ˆκΈ°ν™”λ©΄ webapp.home 처음으둜, μ΄ˆκΈ°ν™”λ©΄
상담전화연결 webapp.call μ£Όλ¬Έμ „ν™”, 상담전화
λ°”λ‘œμ£Όλ¬Έ webapp.order.now λ°”λ‘œμ£Όλ¬Έ, μ£Όλ¬Έν•΄μ€˜
μƒν’ˆκ²€μƒ‰ webapp.product.search <μƒν’ˆλͺ…> μƒν’ˆ μ°Ύμ•„μ€˜, <μƒν’ˆλͺ…> μƒν’ˆ λ³΄μ—¬μ€˜
μƒν’ˆμΆ”μ²œ webapp.rec μΆ”μ²œμƒν’ˆ, μƒν’ˆμΆ”μ²œν•΄μ€˜
λ‹€μŒλ™μ˜μƒλ…ΈμΆœ webapp.vod.next λ‹€μŒλ°©μ†‘μƒν’ˆ, λ‹€μŒμ‹œκ°„μƒν’ˆ
TVνŽΈμ„±ν‘œλ³΄κΈ° webapp.vod.schedule <채널λͺ…> νŽΈμ„±ν‘œ
도움말 webapp.help <채널λͺ…> 도움말, <채널λͺ…> μ•ˆλ‚΄
⚠️ **GitHub.com Fallback** ⚠️