Class: Screen

Mobizen.Socket.Channel.Screen

new Mobizen.Socket.Channel.Screen(socket)

Name Type Description
socket Mobizen.Socket

A provider of Mobizen/Socket API.

Extends

Members

listeners object

inherited name string

The name of channel of socket.

inherited specific object

Store of the channel feature.

inherited tasks object

Store of the tasks.

Type Definitions

inherited protocol Protocol

A provider of the web protocol API.

A provider of Mobizen/Socket API.

Methods

emit(type, payload, data)

Name Type Description
type string
payload object
data object

inherited virtual error(payload, data)

Name Type Description
payload object
data * optional
Name Type Description
action string
data object
Returns:
Type Description
Mobizen.Socket.Channel~Task event emmiter
Returns:
Type Description
Mobizen.Socket.Channel~Task event emmiter

on(type, listener)

Name Type Description
type string
listener function
Name Type Description
type string
data object
Fires:
Returns:
Type Description
Mobizen.Socket.Channel~Task event emmiter

receive(payload, data)

Name Type Description
payload object
data object
Throws:
Will throw an error if receive the unknown payload

Responsable packet transfer.

Name Type Description
cmd string
data *
options object optional

sequence options

Name Type Description
params * optional

send data of operational packet

type string optional

transfer type request or stream

channel string optional

channel of socket

timeout number optional

add an error event of timeout

cancel string| function optional

send cancel signal

Returns:
Type Description
Mobizen.Socket.Channel~Task a task of transfer sequence
Example
var task = this.request('some.command', {
    kind: kind,
    id: id
  }).on('end', function(data) {
    // do somthing
  }).on('error', function(type) {
    // do somthing
  });

send(cmd, data){object}

Name Type Description
cmd string
data object
TODO
  • Union ID 요청 인터페이스 개선할 것
Throws:
Will throw an error if unknown command
Returns:
Type Description
object data of struct

Implement data transfer sequence.

Name Type Description
action string optional

operational signals

options object

sequence options

Name Type Description
params * optional

send data of operational packet

type string optional

transfer type request or stream

channel string optional

channel of socket

timeout number optional

add an error event of timeout

pause string| function optional

send pause signal

resume string| function optional

send resume signal

cancel string| function optional

send cancel signal

TODO
  • EventEmitter의 `pipe()` `unpipe()` 메서드는 스트림 타입인 경우에만 이곳에서 확장
Returns:
Type Description
Mobizen.Socket.Channel~Task a task of transfer sequence
Example
var task = this.sequence('some.command', {
    type: 'stream',
    params: {
      kind: kind,
      id: id
    },
    timeout: 24000,
    pause: 'some.command.pause',
    resume: 'some.command.resume',
    cancel: 'some.command.cancel'
  }).on('data', function(data) {
    // do somthing
  }).on('end', function(data) {
    // do somthing
  }).on('error', function(type) {
    // do somthing
  });

// send pause signal while stream progress
task.pause();
// send resume signal while stream progress
task.resume();
// send cancel signal while stream progress
task.cancel();

Streamable packet transfer.

Name Type Description
cmd string
data *
options object optional

sequence options

Name Type Description
params * optional

send data of operational packet

type string optional

transfer type request or stream

channel string optional

channel of socket

timeout number optional

add an error event of timeout

pause string| function optional

send pause signal

resume string| function optional

send resume signal

cancel string| function optional

send cancel signal

Returns:
Type Description
Mobizen.Socket.Channel~Task a task of transfer sequence
Example
var task = this.stream('some.command', {
    kind: kind,
    id: id
  }, {
    timeout: 24000,
    pause: 'some.command.pause',
    resume: 'some.command.resume',
    cancel: function() {
      this.send('some.command.cancel', {type: 1});
    }.bind(this)
  }).on('data', function(data) {
    // do somthing
  }).on('end', function(data) {
    // do somthing
  }).on('error', function(type) {
    // do somthing
  });

// send pause signal while stream progress
task.pause();
// send resume signal while stream progress
task.resume();
// send cancel signal while stream progress
task.cancel();

inherited task(cmd, event, arg1, arg2, arg3){boolean}

The task of a sequence.

Name Type Description
cmd string
event string
arg1 * optional

receive data 1

arg2 * optional

receive data 2

arg3 * optional

receive data 3

Returns:
Type Description
boolean excuted

Events

inherited media․thumbnail․error

Timeout Error

Type:
Name Type Description
type string

inherited media․thumbnail․load

Type:
Name Type Description
data object

inherited media․thumbnail․timeout

Type:
Name Type Description
data object
comments powered by Disqus