powered by simpleCommunicator - 2.0.56     © 2025 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Caché, Ensemble, DeepSee, MiniM, IRIS, GT.M [игнор отключен] [закрыт для гостей] / [gt.m] Node.js
8 сообщений из 33, страница 2 из 2
[gt.m] Node.js
    #39068098
Valeriu
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Здравствуйте !

Кто может подсказать по поводу отображения
данных на странице при помощью Node js ?
Наблюдаю такую ситуацию:
При поступления первого события со стороны клиента (страница WEB),
GT.M записывает возвращает некоторые данные - все ОК.
При повторном некоторых изменения на клиенте, GT.M записывает
данные, но при возврате, отображаются старые значения.
Перезагрузка страницы помогает решить вопрос, но хочется без этого ...
Я теряю $job..

Спасибо.
test(var1,var2,var3,Ret) ;;Compilation tools WinBuilder :[02.10.2015 09:45:36]
 s ^v1=var1,^v2=var2,^v3=var3
 s name=var2
 s var1="Now Runing Job: "_$job,var2="Variable v2",var3="Variable v3"
 f i=1:1:50 s Ret(i)="Array test string nr. "_i_"   var1="_var1_"   var2="_name_"   var3="_var3_$c(13,10)
 q "GT.M Q Return "_i
var http = require('http'),
    querystring = require('querystring'),
    utils = require('util');
    client = require('/home/node/client');

http.createServer(function (req, res) {
    // set up some routes
    switch(req.url) {
        case '/':
            // show the user a simple form
            console.log("[200] " + req.method + " to " + req.url);
            res.writeHead(200, "OK", {'Content-Type': 'text/html'});
            res.write('<html><head><title>Hello Noder!</title></head><body>');
            res.write('<h1>Welcome Noder, who are you?</h1>');
            res.write('<form enctype="application/x-www-form-urlencoded" action="/formhandler" method="post">');
            res.write('Name: <input type="text" name="username" value="Valeriu Gontia" />');
            res.write('Age: <input type="text" name="userage" value="56" />');
            res.write('<input type="submit" />');
            res.write('</form></body></html');
            res.end();
            break;

        case '/formhandler':

            if (req.method == 'POST') {
                console.log("[200] " + req.method + " to " + req.url);
                var fullBody = '';

                req.on('data', function(chunk) {
                    // append the current chunk of data to the fullBody variable

                    fullBody += chunk.toString();
                });
                req.on('end', function() {

                    client.connect();
                    var ret = '';
                    client.doFunction('test^nodejs',  'test12', fullBody,'test123', ret);
                    console.log("mvar " + client.m_var[4]);


                    // request ended -> do something with the data
                    res.writeHead(200, "OK", {'Content-Type': 'text/html'});

                    // parse the received body data
                    var decodedBody = querystring.parse(client.m_var[4]);
                    // var decodedBody = querystring.parse(fullBody);

                    // output the decoded data to the HTTP response
                    res.write('<html><head><title>Post data</title></head><body><pre>');
                    res.write(utils.inspect(decodedBody));
                    res.write('</pre></body></html>');
                    res.end();
                });

            } else {
                console.log("[405] " + req.method + " to " + req.url);
                res.writeHead(405, "Method not supported", {'Content-Type': 'text/html'});
                res.end('<html><head><title>405 - Method not supported</title></head><body><h1>Method not supported.</h1></body></html>');
            }

            break;
        default:
            res.writeHead(404, "Not found", {'Content-Type': 'text/html'});
            res.end('<html><head><title>404 - Not found</title></head><body><h1>Not found.</h1></body></html>');
            console.log("[404] " + req.method + " to " + req.url);
    }
}).listen(8124); // listen on tcp port 8124 (all interfaces)
...
Рейтинг: 0 / 0
[gt.m] Node.js
    #39068134
Фотография DAiMor
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Судя по всему срабатывает кеш где то, между node.js и браузером еще кто-то есть, кто может кешировать ?
да тот же прокси, может делать так
нужно поставить запрет кеширования в заголовках
Код: plaintext
1.
2.
Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: 0
или так на node.js
Код: javascript
1.
2.
3.
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
response.setHeader("Expires", "0"); // Proxies.


подробнее можно тут почитать
...
Рейтинг: 0 / 0
[gt.m] Node.js
    #39070667
kalin
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Valeriu,
Для gt.m отлично подходит шлюз mgwsi, взаимодействующий с php скрипт.
Пишем в script.php типа
Код: php
1.
m_html("label^programm",$_array);

Данные из gt.m идут потоком через write !!!
php скрипт можно на стороне сервера привязать как к Apache, так и вызывать через shell
Код: php
1.
2.
3.
4.
5.
6.
7.
 $fp=popen('script.php',"r");
  while(!feof($fp))
    {
        echo read($fp, 1024);
    }
    fclose($fp);
}
...
Рейтинг: 0 / 0
[gt.m] Node.js
    #39070827
Valeriu
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
kalin Данные из gt.m идут потоком через write !!!
Один к одному - такой же подход.
Разница только в том, что ВСЕ должно
крутиться на Linux + GT.M + Node.js
WEB клиент приложение уже без разницы..
...
Рейтинг: 0 / 0
[gt.m] Node.js
    #39070934
kalin
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Valeriu,
Если бы я использовал node.js, то рассмотрел бы вот эту технологию EWD.js http://ec2.mgateway.com/ewd/ws/index.html
...
Рейтинг: 0 / 0
[gt.m] Node.js
    #39071462
Valeriu
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
kalin,
Это понятно. Хочется что нибудь по проще
и побольше классического М.
...
Рейтинг: 0 / 0
[gt.m] Node.js
    #39072275
Valeriu, а перепишите-ка, если хотите, вот этот файл boobst.m под GT.M, может быть Вам пригодится. В проекте и set'ы и get'ы и order'ы есть.
...
Рейтинг: 0 / 0
[gt.m] Node.js
    #39072551
Valeriu
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
не рубящий в кашепод GT.M, может быть Вам пригодится. В проекте и set'ы и get'ы и order'ы есть.

Спасибо. Скачал.
Даже удивлен, такой же подход только для Каше...
Я тоже использую M/Wire со своими доработками :
Код: vbnet
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
.......................
cmdKill(input)
 n $zt s $zt=$$zt()
 s gtmbuild("Node")=input
 i gtmbuild("Node")["zmwire" w "-No access allowed to this global"_separatorend q
 k @("^"_gtmbuild("Node"))
 s response="+OK"_separatorend
 w response
 k gtmbuild("Node")
 q
 ;
cmdData(input)
 n $zt s $zt=$$zt()
 s gtmbuild("Node")=input
 s gtmbuild("Value")=$d(@("^"_gtmbuild("Node")))
 w gtmbuild("Value")_separatorend
 q
 ;
cmdGet(input)
 s $zt=$$zt()
 s gtmbuild("Node")=input
 s gtmbuild("Value")=@("^"_gtmbuild("Node"))
 w gtmbuild("Value")
 w separatorend
 q
 ;
cmdKeepAlive(input)
  q
 ;
cmdQuery(input);
 n $zt s $zt=$$zt()
 s gtmbuild("Node")=input
 s gtmbuild("Value")=$q(@("^"_gtmbuild("Node")))
 w gtmbuild("Value")_separatorend
 q
 ;
cmdOrder(input)
 n $zt s $zt=$$zt()
 s gtmbuild("Node")=$p(input,$c(0),1)
 s flag=$p(input,$c(0),2)
 i flag=1 d
 . s gtmbuild("Value")=$o(@("^"_gtmbuild("Node")))
 . w gtmbuild("Value")_separatorend
 i flag=0 d
 . s gtmbuild("Value")=$o(@("^"_gtmbuild("Node")),-1)
 . w gtmbuild("Value")_separatorend
 q
 ;
cmdSet(input)
 n $zt s $zt=$$zt()
 s gtmbuild("Node")=$p(input,$c(0),1)
 s gtmbuild("Value")=$p(input,$c(0),2)
 s @("^"_gtmbuild("Node"))=gtmbuild("Value")
 ;s response="+OK"_separatorend
 ;w response
 k gtmbuild("Node"),gtmbuild("Value")
 q
 ;
cmdXe(input)
 ;
 ; i input["^zmwire" w "No access allowed to this global"_separatorend q
 s gtmbuild("Xecute")=input
 n $zt s $zt=$$zt()
 x "New gtmbuild "_gtmbuild("Xecute")
 s $zt=""
 w separatorend
 k gtmbuild("Xecute"),gtmbuild
 w !
 q
 ;
cmdDo(input)
 ;
 n flag,rtn,head,cik,i,nprm,array,data,ByRef
 s head=$p(input,$c(0))
 s rtn=$p(head,"~",1)       ; RoutineLabel^RoutineName
 s nprm=$p(head,"~",2)      ; nr.parameters
 s flag=$p(head,"~",3)      ; flag
 s lenAll=$p(head,"~",4)    ; len all  -It's not used
 s lenP1=$p(head,"~",5)     ; len par1 -It's not used
 s lenP2=$p(head,"~",6)     ; len par2 -It's not used
 s lenP3=$p(head,"~",7)     ; len par3 -It's not used
 s lenP4=$p(head,"~",8)     ; len par4 -It's not used
 s lenP5=$p(head,"~",9)     ; len par5 -It's not used
 s lenP6=$p(head,"~",10)    ; len par6 -It's not used
 s lenP7=$p(head,"~",11)    ; len par7 -It's not used
 s lenP8=$p(head,"~",12)    ; len par8 -It's not used
 s lenP9=$p(head,"~",13)    ; len par9 -It's not used
 s lenP10=$p(head,"~",14)   ; len par10 -It's not used
 s lenP11=$p(head,"~",15)   ; len par11 -It's not used
 s lenP12=$p(head,"~",16)   ; len par12 -It's not used
 s lenP13=$p(head,"~",17)   ; len par13 -It's not used
 s lenP14=$p(head,"~",18)   ; len par14 -It's not used
 s lenP15=$p(head,"~",19)   ; len par15 -It's not used
 s lenP16=$p(head,"~",20)   ; len par16 -It's not used
 ;
 ; Passing parameters ByRef label^routine(.var1,.var2, ... .var16) return records or Array !!!
 s gtmbuild("gtmstring")=rtn_"("
 f i=2:1:nprm+1 d
 . s gtmbuild("ByRef",i)=$p(input,$c(0),i)
 . s ByRef=".ByRef"_i s gtmbuild("gtmstring")=gtmbuild("gtmstring")_(ByRef_","),passing="ByRef"_i,@passing=gtmbuild("ByRef",i)
 s $e(gtmbuild("gtmstring"),$l(gtmbuild("gtmstring")))=")"
 i nprm=0 s gtmbuild("gtmstring")=rtn ; with no parameter in function
 k i
 i flag="R" d
 . w ""_separator ; Return pseudo parameter ("")
 . n $zt s $zt=$$zt()
 . x "New gtmbuild Do "_gtmbuild("gtmstring")
 . s $zt=""
 . f i=2:1:nprm+1 d
 . . i $d(@("ByRef"_i))\10=0 w @("ByRef"_i)
 . . e  f cik=0:1 s array=$q(@("ByRef"_i_"("_cik_")")) q:array=""  w @array
 . . k @("ByRef"_i)
 . . w separator  ; Separator fragments
 i flag="F" d
 . n $zt s $zt=$$ztx()
 . x "New gtmbuild s ByRef=$$"_gtmbuild("gtmstring")
 . s $zt=""
 . w ByRef_separator
 . f i=2:1:nprm+1 d
 . . i $d(@("ByRef"_i))\10=0 w @("ByRef"_i)
 . . e  f cik=0:1 s array=$q(@("ByRef"_i_"("_cik_")")) q:array=""  w @array
 . . k @("ByRef"_i)
 . . w separator  ; Separator fragments
 w endfragment    ; END Separator
 w !
 q
 ;;

...
Рейтинг: 0 / 0
8 сообщений из 33, страница 2 из 2
Форумы / Caché, Ensemble, DeepSee, MiniM, IRIS, GT.M [игнор отключен] [закрыт для гостей] / [gt.m] Node.js
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]