2 way communication using HTML and Javascript? - javascript

I've been looking for a while for a simple solution to what seems like a relatively simple problem, but I just cannot for the life of me manage to find it.
So here is what I am trying to do:
Server (Hosting an HTML file, Has a variable, x, which is a javascript variable)
Server is running on my local network (192.168.x.x, with no security)
Client, PC, has access to SSH, Telnet, whatever, and wants to communicate over TCP/IP
So my question is this: How can I get the client to send a value, over TCP/IP, to the server, changing the value of that variable?
I can see that there are rather complex ways to do this, using websockets, sockJS, and other complex solutions, but if anyone knows of a super simple way to do this, please let me know.
Thanks :)

You'll want to use sockets. I'd recommend socket.io http://socket.io/

Related

DataBase Connectivity on the client side using (JavaScript)

I have a question which really Poked me for several days... I have came across a hurdle, the problem is that i need the Php application on the server side and the database to be on the client side... and the application should communicate with each other very nicely..
Javascript was the best option coming in my mind... The problem is that i dont have any idea how do i make this thing applicable...
If any one have any knowledge for that please share that stuff with me...
Thanks in advance...
Your question is kind of generic, so i can't determine whether you REALLY need a database stored on the client-side, and why. However if that is what you truly desire, HTML5 has client-side storage capabilities which can be used for running apps locally in the browser without having to pass data back to the server:
Some background and usage
Tutorial

Call server side C++ from webpage

I would like to use node.js/express and socket.io to retrieve data off of a piece of hardware through a web browser, but I really dont know where to start. I currently have express serving a webpage. I would like to retrieve and display raw data in realtime (graph form) from a sensor, for this reason, socket.io looked promising. I would also need to use some server side code (c, c++?) to do some processing on this data and display the results on the page. Is Ajax the best way to do this?
I do not really have much experience with this sort of thing, so is this the best way to go about this? Better options?
you can use web sockets and this c++ library. http://libwebsockets.org
and there is pretty example of its usage. http://martinsikora.com/libwebsockets-simple-http-server

socket.io - listen on multiple namespaces with one packet?

We are migrating from APE to socket.io. So far, so good, but... is there way to join multiple namespaces with one packet? I've tried something like that:
websocket received data packet 1::/public,/foo,/bar,/baz
but that doesn't work. What is best way to achieve that?
Edit:
Ok, it seems that packet works, problem lies on server end. Is there way to intercept all namespaces with on('connection')? We have dynamically created namespaces, so there is no possibility for us to include them all on server side code.
I found on Socket.io mailing group that it is technically possible, but it's much better to use rooms feature, and I did that in that way.

Best Way to Transfer Data to and from a MySQL Database

I wonder whether someone may be able to help me please. For a while now I've been working on the Javascript and HTML elements of the Google Maps V3 api. I now want to look at how I'm going to transfer the data to and from MySQL database.
I've read quite a lot of documentation on the Internet on the various methods of transferring this information but I'm not too sure of the best route to take.
I just wondered whether it would be possible that someone with a lot more experience than I could perhaps give me a bit of advice and direction please on the best way to transfer this data.
Many thanks and kind regards
it's a fairly broad question, but mostly dependent on your implementation. Are you already interfacing with the API using a server side language, or just all with Javascript? If everything is being done on the client side, then you would want to consider some sort of AJAX/form functionality to get the data from the client to a server side script. If you are doing any of this on the server side, then you can cut out the AJAX middle man and run SQL commands via PHP or whatnot as you are interfacing with the API.
I would recomend MySQl Dump. Its fairly simple and there is plenty of documentation on how to do it.

Is there a good library in Node for asynchronous communication between the client and server?

Instead of creating every websocket and defining the entire structure by hand, is there a library that will let me run a function on the Node.js server, that can call a related function on all clients connected to the server simultaneously? Likewise, can I securely call a server function FROM the client browser? I feel like every time I have to construct a command to send over the web socket, I'm working on the transmission layer instead of the application layer, and I want to be thinking at the higher layer the entire time.
I wouldn't mind building something like this myself if it doesn't already exist, but I have a hard time believing this isn't solved on node already.
What you are really looking for is an node.js RPC solution. Here are a couple of node.js RPC options:
DNode - shows some good examples.
BERT-RPC
nowjs
I have not personally used them, but they look like they have good potential.
Try to look at now.js.
Try msg-rpc, it just provides the rpc support you need, also no particular requirement for the websocket library of server/client you already have. Tell how to send out a message and forward the messages received, that's all.

Categories