Mercurial > pub > ImplabJs
comparison core/src/js/messaging/Client.js @ 34:27e8e9e38e07 default tip
Слияние
author | nickolay |
---|---|
date | Wed, 05 Jun 2019 20:44:15 +0300 |
parents | acdcdf1a8d21 |
children |
comparison
equal
deleted
inserted
replaced
33:8af8e840dd49 | 34:27e8e9e38e07 |
---|---|
1 define( | |
2 [ "dojo/_base/declare", "dojo/_base/lang", "dojo/Evented", "../log/_LogMixin" ], | |
3 | |
4 function(declare, lang, Evented, _LogMixin) { | |
5 return declare([ Evented, _LogMixin ], { | |
6 _session : null, | |
7 _destination : null, | |
8 _id : null, | |
9 | |
10 constructor : function(session, destination, options) { | |
11 this._destination = destination; | |
12 this._session = session; | |
13 }, | |
14 | |
15 getDestination : function() { | |
16 return this._destination; | |
17 }, | |
18 | |
19 start : function() { | |
20 var me = this; | |
21 return me._session.createClient(me.prepareOptions({})).then( | |
22 function(id) { | |
23 me._id = id; | |
24 return me; | |
25 }); | |
26 }, | |
27 | |
28 prepareOptions : function(options) { | |
29 var me = this; | |
30 options.mode = me.getMode(); | |
31 options.destination = me.getDestination(); | |
32 options.client = function(msg) { | |
33 me.process(msg); | |
34 }; | |
35 return options; | |
36 }, | |
37 | |
38 process : function(msg) { | |
39 this.warn("Messages are not acceped by this client"); | |
40 }, | |
41 | |
42 stop : function() { | |
43 var me = this; | |
44 if (me._id) { | |
45 me.log("stop"); | |
46 return me._session.deleteClient({'clientId': me._id}).then(function() { | |
47 me._id = null; | |
48 return me; | |
49 }); | |
50 } | |
51 }, | |
52 | |
53 toString : function() { | |
54 return "[" | |
55 + [ | |
56 this.getMode().toUpperCase(), | |
57 this.getDestination(), | |
58 this._id ].join(',') + "]"; | |
59 } | |
60 }); | |
61 }); |