annotate src/implab/messaging/Client.js @ 12:23be39fd3851

fixed typo in template-compile the built-in function 'print'
author cin
date Thu, 24 Aug 2017 04:30:11 +0300
parents 7d7059d2a810
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(
2
7d7059d2a810 Подправлены пути в пакетах
egor
parents: 0
diff changeset
2 [ "dojo/_base/declare", "dojo/_base/lang", "dojo/Evented", "../log/_LogMixin" ],
0
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
3
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
4 function(declare, lang, Evented, _LogMixin) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
5 return declare([ Evented, _LogMixin ], {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
6 _session : null,
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
7 _destination : null,
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
8 _id : null,
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
9
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
10 constructor : function(session, destination, options) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
11 this._destination = destination;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
12 this._session = session;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
13 },
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 getDestination : function() {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
16 return this._destination;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
17 },
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
18
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
19 start : function() {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
20 var me = this;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
21 return me._session.createClient(me.prepareOptions({})).then(
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
22 function(id) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
23 me._id = id;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
24 return me;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
25 });
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
26 },
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 prepareOptions : function(options) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
29 var me = this;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
30 options.mode = me.getMode();
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
31 options.destination = me.getDestination();
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
32 options.client = function(msg) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
33 me.process(msg);
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
34 };
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
35 return options;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
36 },
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
37
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
38 process : function(msg) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
39 this.warn("Messages are not acceped by this client");
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
40 },
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
41
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
42 stop : function() {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
43 var me = this;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
44 if (me._id) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
45 me.log("stop");
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
46 return me._session.deleteClient({'clientId': me._id}).then(function() {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
47 me._id = null;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
48 return me;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
49 });
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
50 }
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
51 },
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
52
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
53 toString : function() {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
54 return "["
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
55 + [
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
56 this.getMode().toUpperCase(),
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
57 this.getDestination(),
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
58 this._id ].join(',') + "]";
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
59 }
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
60 });
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
61 });