Sunday 15 May 2011

node.js - POST to controller action in node and trigger websocket connection to client -


New to nodes and web sites, I'm trying to create something contrary to a particular game or chat app.

I need to post some variables in an action, do some lookup and then connect with the wars from the cloud. I really do not know that this is possible.

My biggest problem is that I is not a specific JS client , no browser, nada My only client is Paython WebCraft client. It is okay to connect to this server ... Okay, they can ping a server - I'm trying with socket.o, faye and wallet. I like to use socket. O

For example, if I post it:

  curl -x post 'http: // localhost: 8080 / timeout? ID = 1238763876 & amp; Time = 27365716576 & amp; Bla = stuff '  

In my app.js I have something like this (some bits are unavailable, my socket example):

  app.get ('/', Function (rik, ridge) {res.sendfile (__DERNAM + '/ public / index.html');}); Search for App.post ('/ timeout', function (req, res) {// socket, yet console.log has not been applied ('I got a private message', from, 'say', msg); On io.sockets ('connections', function (socket) {io.sockets.emit (' this', will be: 'will be received by each person});});}); Server.listen (app.get ('port'), function () {console.log ('listen to express server on port' + app.get ('port'));};   

The route works, but when I post, I do not get any harm and there is no error - like I said, I'm new to the node by rail. I am hopeful that this is something directly ahead.

Is it possible to do this? Is this the way to go about it or should I try to do something else?

Detected with:

  app post (' / Commands :: Action /: To ', Function (Rick, Race) {target_socket = connections [req.params.to] if (target_socket) {console log (rick scury) io.sockets.socket (target_socket.id). Emit ('name', 'stuff); res.send (200);} else res.send (404);});   



No comments:

Post a Comment