UWSHelper

UWSHelper

new UWSHelper(options)

서버 정보를 가지는 Helper 인스터스를 생성

Example
new UWSHelper({
     url: "http://127.0.0.1:8080",
     app_id: "com.example.uracle",
     cuid: "LoginId",
     setting: {},
   });
Parameters:
Name Type Description
options object
Properties
Name Type Description
url string

UPMC URL

app_id string

APP ID

cuid string

CUID

setting object

SETTINGS (default 기준 override)

Members

(static) default :object

Properties:
Name Type Description
path string

websocket 연결시 path (/webmqtt)

connectOptions object

websocket 연결시 옵션

Properties
Name Type Description
timeout number

대기시간 (10)

keepAliveInterval number

session 유지 시간 (60)

useSSL boolean

https 프로토콜 여부 (false)

cleanSession boolean

session clear 여부 (true)

mqttVersion number

mqtt version (3)

Push Instance 생성시 default 세팅 값을 merge하여 생성한다.

Type:
  • object
Example
UWSHelper.default.connectOptions.timeout = 30;

Methods

(static) supportValidator() → {boolean}

브라우저의 cors 와 WebSocket 지원 유무를 체크한다. WebSocket은 IE10 이상에서 지원한다.

Example
if(UWSHelper.supportValidator()) {
  var helper = new UWSHelper(options);
} else {
  alert('해당 브라우저는 WebSocket을 지원하지 않습니다.');
}
Returns:

result

Type
boolean

(async) autoClient(callback)

자동으로 Websocket Client를 생성

Example
helper.autoClient(function (client) {
  // 연결이 끊어 졌을때
  helper.onConnectionLost = function (e) {
    console.log("webSocket 연결 끊어짐!");
    console.log(e);
  };
  // 메세지가 도착했을때
  // Message를 전달받는다.
  helper.onMessageArrived = function (msg) {
    console.log("WebSockert 메세지 도착!");
    console.log(msg);
  };
  helper.onSuccess = function (e) {
    // 웹소켓 연결 성공 시
    console.log("WebSocket 연결 성공!");
    console.log(e);
  };
  helper.onFailure = function (e) {
    // 웹소켓 연결 실패 시
    console.log("WebSocket 연결 실패!");
    console.log(e);
  };

  var options = helper.connect();
});
Parameters:
Name Type Description
callback autoClientCallback

callback(client:Client)

clearAuthKey()

LocalStorage에 저장된 AuthKey를 삭제한다.

connect(connectOptions)

MQTT.Client를 통해 websocket에 연결을 시도한다.

Parameters:
Name Type Description
connectOptions object

websocket 연결시 옵션

Properties
Name Type Description
timeout number

대기시간

keepAliveInterval number

session 유지 시간

useSSL boolean

https 프로토콜 여부

cleanSession boolean

session clear 여부

mqttVersion number

mqtt version

createClient(path) → {Client}

websocket 클라이언트를 생성한다.

Parameters:
Name Type Description
path string

upns 에 연결될 path정보 (default.path)

Returns:
Type
Client

(async) getInfoInPsid(callback)

저장된 psid가 있는 경우, UPNS 연결 정보를 받아온다.

Parameters:
Name Type Description
callback requestCallback

콜백

getPsid() → {string}

LocalStorage에서 psid를 가져온다.

Returns:

psid

Type
string

(async) registerServiceAndUser(callback)

UPMC에 유저를 PUSH서비스에 가입한다.

Parameters:
Name Type Description
callback requestCallback

콜백

(async) setAuthKey(callback)

UPMC에 AuthKey를 요청, LocalStorage에 저장한다.

Parameters:
Name Type Description
callback requestCallback

콜백 함수

setPsid(psid)

LocalStorage에 psid를 저장한다.

Parameters:
Name Type Description
psid string