comparison src/implab/messaging/Destination.js @ 0:fc2517695ee1

Initial commit, draft import of existing work
author cin
date Thu, 01 Jun 2017 13:20:03 +0300
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:fc2517695ee1
1 define([ "dojo/_base/declare", "./Listener" ],
2
3 function(declare, Listener) {
4 return declare(null, {
5 _session : null,
6 _destination : null,
7 _listenerClass : null,
8
9 constructor : function(session, destination, options) {
10 if (!session)
11 throw new Error("A session is required");
12 if (!destination)
13 throw new Error("A destination is required");
14
15 this._session = session;
16 this._destination = destination;
17 if (options) {
18 if (options.listenerClass)
19 this._listenerClass = options.listenerClass;
20 }
21 },
22
23 listen : function(callback) {
24 var factory = this._listenerClass || Listener;
25 var listener = new factory(this._session, this._destination, {
26 listener : callback
27 });
28 listener.start();
29
30 return listener;
31 }
32
33 });
34 });