annotate core/src/js/messaging/Destination.js @ 30:2dfba21cd879

sync
author cin
date Wed, 27 Jun 2018 02:46:14 +0300
parents acdcdf1a8d21
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
1 define([ "dojo/_base/declare", "./Listener" ],
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
2
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
3 function(declare, Listener) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
4 return declare(null, {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
5 _session : null,
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
6 _destination : null,
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
7 _listenerClass : null,
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
8
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
9 constructor : function(session, destination, options) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
10 if (!session)
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
11 throw new Error("A session is required");
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
12 if (!destination)
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
13 throw new Error("A destination is required");
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
14
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
15 this._session = session;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
16 this._destination = destination;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
17 if (options) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
18 if (options.listenerClass)
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
19 this._listenerClass = options.listenerClass;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
20 }
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
21 },
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
22
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
23 listen : function(callback) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
24 var factory = this._listenerClass || Listener;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
25 var listener = new factory(this._session, this._destination, {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
26 listener : callback
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
27 });
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
28 listener.start();
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
29
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
30 return listener;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
31 }
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
32
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
33 });
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
34 });