코드 실행(스트리밍)

The streaming mode provides a lightweight and interactive method to connect with the session containers.

코드 실행

  • URI: /stream/session/:id/execute

  • Method: GET Websocket으로 업그레이드

:HTTP를 통해 긴 폴링 방식을 사용하는 doc:`exec-batch`와 :doc:`exec-query`실시간 스트리밍 버전이다.

(구성 중)

버전 v4.20181215에 추가.

터미널 에뮬레이션

  • URI: /stream/session/:id/pty?app=:service

  • Method: GET Websocket으로 업그레이드

이 엔드포인트는 네이티브 웹소켓을 통해 Json 객체의 이중 연속 스트림을 제공한다.웹소켓은 바이너리 스트림을 지원하지만, 서로 다른 브라우저를 통한 Javascript의 타이핑된 배열 지원에서 이상한 점을 방지하기 위해 현재는 JSON 페이로드만 전달하는 TEXT 메시지에 의존하고 있다.

서비스 이름은 :ref:`the session creation API <create-session-api>`가 반환한 :ref:`service port objects <service-port-object>`의 리스트에서 가져와야 합니다.

참고

우리는 socket.io나 SockJS같은 기존 웹소켓 에뮬레이션 인터페이스를 제공하지 *않습니다.*기존 브라우저 사용자를 지원하려면 자신의 프록시를 설정해야 합니다.

버전 v4.20181215에서 변경: service 쿼리 매개변수를 추가하십시오.

매개변수들

매개변수

타입

설명

:id

slug

The session ID.

:service

slug

연결할 서비스 명

클라이언트-대-서버 프로토콜

엔드포인트에서 다음 네 가지 유형의 입력 메시지를 수락합니다.

표준 입력 스트림

모든 ASCII (및 UTF-8) 입력은 반드시 base64 문자열로 인코딩되어야 합니다.문자에는 제어 문자도 포함될 수 있습니다.

{
  "type": "stdin",
  "chars": "<base64-encoded-raw-characters>"
}

터미널 크기 조정

터미널 크기를 주어진 행과 열 수로 설정하십시오. 스스로 계산을 해야 합니다.

예를 들어, 웹브라우저의 경우, ASCII 문자 하나만 포함된 터미널 컨테이너 요소와 동일한 (monospace) 글꼴 스타일을 이용해서, 임시로 생성된 보이지 않는 HTML 너비와 높이를 측정하여 간단한 계산을 할 수 있다.

{
  "type": "resize",
  "rows": 25,
  "cols": 80
}

Use this to keep the session alive (preventing it from auto-terminated by idle timeouts) by sending pings periodically while the user-side browser is open.

{
  "type": "ping",
}

재시작

Use this to restart the session without affecting the working directory and usage counts. Useful when your foreground terminal program does not respond for whatever reasons.

{
  "type": "restart",
}

서버-대-고객 프로토콜

표준 결과/에러 스트림

Since the terminal is an output device, all stdout/stderr outputs are merged into a single stream as we see in real terminals. This means there is no way to distinguish stdout and stderr in the client-side, unless your session applies some special formatting to distinguish them (e.g., make all stderr otuputs red).

The terminal output is compatible with xterm (including 256-color support).

{
  "type": "out",
  "data": "<base64-encoded-raw-characters>"
}

Server-side errors

{
  "type": "error",
  "data": "<human-readable-message>"
}