map 오브젝트를 선언하고 Server 클래스를 상속받아 접속한 클라이언트의 정보를 저장합니다.

    코드 6-9 Server 클래스 상속받기

    예제 파일 : distributor.js

    var map = {};
    class distributor extends require('./server.js') {  // ➊ Server 클래스 상속
        constructor() {
            // ➋ Server 클래스 생성자 호출
            super("distributor", 9000, ["POST/distributes", "GET/distributes"]);
        }
    }
    
    new distributor();

    extends 키워드를 이용해 server.js 파일에 있는 Server 클래스를 상속받습니다(). 생성자에 이름과 포트 번호, 처리 가능한 프로토콜 정보를 전달합니다().

    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.