Class: Channel

Mobizen.Socket.Channel

A Base Class of Socket Channels.

new Mobizen.Socket.Channel(socket, name)

Name Type Description
socket Mobizen.Socket

A provider of Mobizen/Socket API.

name string

The name of channel of socket.

Requires

Classes

Data
Local
Screen
Task

Members

name string

The name of channel of socket.

specific object

Store of the channel feature.

tasks object

Store of the tasks.

Type Definitions

protocol Protocol

A provider of the web protocol API.

A provider of Mobizen/Socket API.

Methods

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
Name Type Description
type string
data object
Fires:
Returns:
Type Description
Mobizen.Socket.Channel~Task event emmiter

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
  });

virtual send()

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();

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

virtual unbind()

inner capitalize(str){string}

Name Type Description
str string
Returns:
Type Description
string capitalized

inner extend(destination, source){object}

Object Extend.

Name Type Description
destination object

A destination object.

source object optional

A source object.

Returns:
Type Description
object Extended object.

inner onendmediathumbnail(data)

Name Type Description
data object
Listens to Events:

inner onerrormediathumbnail(type)

Name Type Description
type string
Listens to Events:

Events

media․thumbnail․error

Timeout Error

Type:
Name Type Description
type string
Listeners of This Event:

media․thumbnail․load

Type:
Name Type Description
data object
Listeners of This Event:

media․thumbnail․timeout

Type:
Name Type Description
data object
Listeners of This Event:
comments powered by Disqus