GraphStream: Interactive Web Application - javascript

I'm trying to develop an interactive web application using GraphStream. The idea is to run a couple of community detection algorithms on graphs and visualize them. I wish to use D3.js as graph rendering framework and use GraphStream library in a java websocket server ( Tomcat ) that runs the algorithms. I wish to know if GraphStream already has websocket capabilities that could directly talk to client ( browser ) websocket endpoint. Suggestions for a more correct or feasbile architecture are also welcome.

Great idea. There is a WebSocket implementation that provides GraphStream's event model to the browser. It implements a network protocol, GS-NetStream.
The actual version is compatible with gs-core v1.3.
You can run the exemples from the test/ folder.
In the test folder, run these commands in that order:
Install dependencies : npm install ws express
Compile the Test1.java with gs-core-1.3 in the classpath: javac -cp path/to/gs-core-1.3.jar:. Test1.java
Run the node server : node Test1server.js
Run the Java app :java -cp path/to/gs-core-1.3.jar Test1
go to http://localhost:8080/Test1.html
Use the code in Test1.html as an example for your project

Related

Connect to OpenVPN server through Node.js

I’m trying to create a GUI client for connecting to OpenVPN servers using electron and node but I’m struggling to figure out how to actually connect to the servers using the .ovpn files.
My question is what is the best way to connect to an OpenVPN server using node? Would it be best to Tun terminal commands like
“openvpn—config path to config”
Or is there another way applications like tunnelblick do it that might be easier or more efficient?
Hello I have been working with electron and ovpn on my last project, so here are a few tips.
VPNs require admin/root privilege in order to get setup, so running child_process.spawn on openvpn --config <path> will fail unless your electron app is being ran via sudo/admin privilege.
You can also use electron-sudo package, link here. This is basically a child process spawn with sudo/admin. Aka, app runs normally, but vpn command runs with sudo.
However, if your client is sketchy about giving you sudo/admin, the VPN must be ran separately prior to launching your app.
All in all its a admin/sudo thing.
Hope this helps.

Testing a Single Page Application while simulating the backend

I have a single page application developed using javascript, react and redux that communicates with the backend via web socket, rest and json.
I wish to explore the possibility of working independently of the backend, both as I develop and in terms of treating the front end as a subsystem and performing subsystem tests on it.
Is this a good approach? What tools would you recommend? For example, I have used selenium previously with python. Would it be a sensible option for me to write my own simple test environment using a selenium api where tests are configured in their setup to respond to rest requests from the front end in the appropriate manner. Maybe there are better approaches.
I think npm provide http-server
You can run server in your project dir and it should be server on localhost.
But if you are using Linux or Mac, the easiest way will be:
$ cd you_app_folder
$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...
As python is built in on mac and Linux it is easiest way as I said.

How to use a browser on a remote server for an automated tests

I inherited a project where the person wrote tools to test our site's UI using JQuery and JS.
I don't know too much about it other than it requires a browser to be spawned and I think the tool uses JS to interact with iframes to see if it's the expected values.
My job is to get this tool to run on a remote server and post the results to Jenkins.
The remote test server and staging server is linux. From our staging server, I want to write a script to spawn a browser and run cmds from the tool to test our UI. I ran the following manually:
ssh -X user#remote_test_server /usr/bin/firefox
However, the remote server says:
Error: no display specified
Is there a way to spawn a browser for automated testing from one headless server to another? Thanks in advance for your help.
I faced a similar problem when I tried to automate a GUI installation program. While there are quite some different possibilities to choose from (e.g. Xnest, Xephyr?), I ended up using vncserver, because it's relatively easy to debug the GUI session this way.
You need to create a vncpassword file, I think:
mkdir -p $HOME/.vnc
chmod 0700 $HOME/.vnc
echo MyLittlePassword | vncpasswd -f > $HOME/.vnc/passwd
chmod 0600 $HOME/.vnc/passwd
Starting the server is then quite straightforward
vncserver
export DISPLAY=:1
/usr/bin/firefox&
...
Now it is possible to connect to the VNC server with a VNC viewer of your choice. But beware there may be no window manager, depending on the X startup scripts of your environment.
Shutting the server down
vncserver -kill :1
In the configuration of Jenkins project , specify the
Build Environment
Start Xvfb before the build, and shut it down after.
#

Bluetooth in Meteor?

I'm pretty new to Meteor and web development and such.
My essential question is: is there a 'right' way to communicate with a client's Bluetooth hardware in Meteor/js?
Currently, I'm thinking of writing a driver that takes the Bluetooth data and sends it in a stream to localhost, but that seems a little bit roundabout.
You would have to go via an npm module in Meteor. For this you need to make a package that uses something like bluetooth-serial-port to allow Meteor to communicate with the device using the host device's bluetooth serial port (https://npmjs.org/package/bluetooth-serial-port) (You will need the bluetooth development headers too)
Avital has made a package demonstrating how to use npm modules with meteor : https://github.com/avital/meteor-xml2js-npm-demo

Installing NodeJS and SocketIO in a Remote Server

My project is a Real Time Two-Player Facebook Game, and what I need is a tool that will help me build the game with quick responses to enable the "Real Time" function of the game. I have just found out about the Node JS and Socket IO. I have some knowledge in JavaScript so I stepped up and watched a few tutorials that discuss the functions of Node JS and Socket IO.
Here's the link to the videos that I have watched:
http://www.youtube.com/watch?v=mSE6xHkcX0w
I understand the basic of the Node JS and Socket IO and successfully installed it in my localhost. The problem is when I uploaded the files from my localhost to my remote server, some functions of the program are not working well. I don't know how to node my JavaScript file when it is on the server, because if it's in my localhost, I am using command prompt to run it.
node app.js
Node is not a web framework.
Chances are, you're using a web host that's generalized for web frameworks like PHP and Ruby on Rails. You're going to need virtual private server hosting, or Node-specific hosting, because Node requires a virtual machine to run. You otherwise won't be able to run Node Package Manager or Node itself.
Joyent has provided a list of hosts here.
If you chose to use a VPS or dedicated machine, an installation guide would be found here. This is how you would install Node on CentOS.
wget http://nodejs.org/dist/v<version>/node-v<version>.tar.gz
tar -zxf node-v<version>.tar.gz
cd node-v<version>
./configure
make -j <number of cores>
make install

Categories