Материал из Module developer
SubDevice.SendEx
Method can be used only with drivers AV & Custom Systems (HTTP). It allows to send a data array with indication of parent object (execution context) to equipment. A number of events can be added inside SendEx that send data about their work to functions. Events allow to keep track of getting data from HTTP server and process different staged of working with a server.
Синтаксис
SubDevice.SendEx(Data, Object)
| Название | Пример | Описание |
| Data | [a, b, c] | type: array data array to send |
| Object | this | type: Object parent object |
| На выходе |
-
Пример
var l_oDevice = module.GetDevice("Server REST"); //Getting a device var l_oSubDevice = module.AddSubDevice("SubDevice 1", l_oDevice); //creating a subdevice l_oSubDevice.SendEx({ Type: "POST", Url: "/html/login", Data: ["Password=2007&name=authform&Login=admin"], Headers: {"Content-Type": "application/x-www-form-urlencoded"}, cbReceiveText: function(text, code, headers) {IR.Log("cbReceiveText "+text+code+headers);}, cbReceiveData: function(text, code, headers) {IR.Log("cbReceiveData "+text+code+headers);}, cbReceiveCode: function(code) {IR.Log("cbReceiveCode "+code);}, cbReceiveKey: function(key,value) {IR.Log("cbReceiveKey "+key+value);}, cbReceiveStartBody: function(stream) {IR.Log("cbReceiveStartBody "+stream);}, cbReceivePartBody: function(stream) {IR.Log("cbReceivePartBody "+stream);}, cbReceiveEndBody: function(size) {IR.Log("cbReceiveEndBody "+size);}, cbTimeOut: function() {IR.Log("cbTimeOut");}, cbReceiveStream: function(stream, code, headers) {IR.Log("cbReceiveStream "+stream+code+headers);} }); l_oSubDevice.SendEx({ Type: "GET", Url: "/json/ok/server/channel", Headers: {"Cookie":"ir-session-id=o8lKdEvw2ZlU"}, cbReceiveText: function(text, code, headers) {IR.Log("cbReceiveText "+text);} });
