Show:

Streams Class

Extends Base.Streams
Module: Streams

Static methods for the Streams model

Methods

define

(
  • type
  • ctor
  • methods
)
static

Call this function to set a constructor for a stream type

Parameters:

  • type String

    The type of the message, e.g. "Streams/chat/message"

  • ctor String | Function

    Your message's constructor, or path to a javascript file which will define it

  • methods Object

    An optional hash of methods. You can also override methods of the Stream object, such as "url".

fetch

(
  • asUserId
  • publisherId
  • streamName
  • callback=null
  • [fields='*']
  • [options={}]
)
static

Retrieve stream with calculated access rights

Parameters:

  • asUserId String

    The user id to calculate access rights

  • publisherId String

    The publisher Id

  • streamName String | Array | Db.Range

    The name of the stream, or an array of names, or a Db.Range

  • callback=null Function
    Callback receives (err, streams) as parameters
  • [fields='*'] String optional

    Comma delimited list of fields to retrieve in the stream. Must include at least "publisherId" and "name". since make up the primary key of the stream table. You can skip this argument if you want.

  • [options={}] Object optional

    Provide additional query options like 'limit', 'offset', 'orderBy', 'where' etc.

fetchOne

(
  • asUserId
  • publisherId
  • streamName
  • [callback=null]
  • [fields='*']
  • [options={}]
)
static

Retrieve stream with calculated access rights

Parameters:

  • asUserId String

    The user id to calculate access rights

  • publisherId String

    The publisher Id

  • streamName String

    The name of the stream

  • [callback=null] Function optional

    Callback receives the (err, stream) as parameters

  • [fields='*'] String optional

    Comma delimited list of fields to retrieve in the stream. Must include at least "publisherId" and "name". since make up the primary key of the stream table. You can skip this argument if you want.

  • [options={}] Object optional

    Provide additional query options like 'limit', 'offset', 'orderBy', 'where' etc.

getObservers

(
  • publisherId
  • streamName
  • [callback=null]
)
static

Retrieve socket.io clients registered to observe the stream by sending "Streams/join" events through the socket.

Parameters:

  • publisherId String

    The publisher Id

  • streamName String

    The name of the stream

  • [callback=null] Function optional

    Callback receives a map of {clientId: socketClient} pairs

getParticipants

(
  • publisherId
  • streamName
  • [callback=null]
)
static

Retrieve stream participants

Parameters:

  • publisherId String

    The publisher Id

  • streamName String

    The name of the stream

  • [callback=null] Function optional

    Callback receives a map of {userId: participant} pairs

iconUrl

(
  • icon
  • [size=40]
)
String static

Calculate the url of a stream's icon

Parameters:

  • icon String

    the value of the stream's "icon" field

  • [size=40] Number optional

    the size of the icon to render. Defaults to 40.

Returns:

String:

the url

isStream

(
  • testing
)
Boolean static

Use this to check whether variable is a Q.Streams.Stream object

Parameters:

  • testing Mixed

Returns:

listen

(
  • options={}
)
Boolean static

Start internal listener for Streams plugin. Accepts messages such as
"Streams/Stream/join", "Streams/Stream/leave", "Streams/Stream/create", "Streams/Stream/remove", "Streams/Message/post", "Streams/Message/postMessages", "Streams/Stream/invite"

Parameters:

  • options={} Object

    So far no options are implemented.

Returns:

Boolean:

Whether the server has started

messageHandler

(
  • msgType
  • callback
)
static

Register a message handler

Parameters:

  • msgType String

    Type of stream

  • callback Function

    The handler for stream messages

Properties

_messageHandlers

Object private

ACCESS_SOURCES

Object

Access sources

ADMIN_LEVEL

Object

Admin levels

ADMIN_LEVEL.invite

Integer final

Able to create invitations for others, granting access and permissions up to what they themselves have

Default: 20

ADMIN_LEVEL.manage

Integer final

Can approve posts, and give people any adminLevel < 'manage'

Default: 30

ADMIN_LEVEL.max

Integer final

Max admin level

Default: 40

ADMIN_LEVEL.none

Integer final

Cannot do anything related to admin / users

Default: 0

ADMIN_LEVEL.own

Integer final

Can give people any adminLevel <= 'own'

Default: 40

ADMIN_LEVEL.tell

Integer final

Can prove things about the stream's content or participants

Default: 10

clients

Object

Stores socket.io clients observing streams

clients

Object

Stores streams that socket.io clients are observing

READ_LEVEL

Object

Read levels

READ_LEVEL.content

Integer final

Can see the stream's content

Default: 20

READ_LEVEL.max

Integer final

Max read level

Default: 40

READ_LEVEL.messages

Integer final

Can play stream in a player

Default: 40

READ_LEVEL.none

Integer final

Can't see the stream

Default: 0

READ_LEVEL.participants

Integer final

Can see participants in the stream

Default: 30

READ_LEVEL.relations

Integer final

Can see relations to other streams

Default: 25

READ_LEVEL.see

Integer final

Can see icon and title

Default: 10

socketServer

SocketNamespace private

WRITE_LEVEL

Object

Write levels

WRITE_LEVEL.close

Integer final

Don't delete, just prevent any new changes to stream however, joining and leaving is still ok

Default: 40

WRITE_LEVEL.closePending

Integer final

Can post a message requesting to close the stream

Default: 35

WRITE_LEVEL.edit

Integer final

Can post messages to edit stream content immediately

Default: 30

WRITE_LEVEL.join

Integer final

Can become a participant, chat, and leave

Default: 10

WRITE_LEVEL.max

Integer final

Max write level

Default: 40

WRITE_LEVEL.messages

Integer final

Can post messages which appear immediately

Default: 20

WRITE_LEVEL.none

Integer final

Cannot affect stream or participants list

Default: 0

WRITE_LEVEL.postPending

Integer final

Can post messages, but manager must approve

Default: 15

WRITE_LEVEL.relate

Integer final

Can post messages relating other streams to this one

Default: 23

WRITE_LEVEL.relations

Integer final

Can update properties of relations directly

Default: 25

WRITE_LEVEL.suggest

Integer final

Can post messages requesting edits of stream

Default: 28

WRITE_LEVEL.vote

Integer final

Can vote for a relation message posted to the stream.

Default: 13

Attributes

ACCESS_SOURCES['contact']

Integer final

From contact

Default: 1

ACCESS_SOURCES['direct']

Integer final

Direct access

Default: 2

ACCESS_SOURCES['inherited_contact']

Integer final

Inherited from contact

Default: 4

ACCESS_SOURCES['inherited_direct']

Integer final

Inherited direct access

Default: 5

ACCESS_SOURCES['inherited_public']

Integer final

Inherited public access

Default: 3

ACCESS_SOURCES['public']

Integer final

Public access

Default: 0