-
Notifications
You must be signed in to change notification settings - Fork 1
XSocketsNodeJs Test
TODO: Change to NDC protocol and add NDC protocol tutorial
###Pre-Req
- Before running the test you should have setup a XSockets self-hosted server
- It will be easy to write this in Visual Studio since we have NodeJS-tools installed!
Create a new file with nano sockettest.js
and write a simple test. Replace the IP with the IP of your development machine.
var xsockets = require('xsockets.net');
var c = new xsockets.TcpClient('127.0.0.1', 8080, ['chat']);
var g = c.controller('chat');
g.on('say', function(d) {
console.log('say',d);
g.send('bar','hello from nodejs');
});
g.onopen = function(ci) {
console.log('connected controller chat');
g.send('say', {text:'bar'});
}
c.onconnected = function(d) {
console.log('connected', d);
}
c.open();
###Test
Run the test with node sockettest.js
Then open up Putty and connect to the same sever as the script, this would be the 192.168.x.x
of your machine.
Then type in PuttyProtocol
in Putty to do a handshake.
Then send a message to nodejs by typing generic|foo|hello from putty
var xsockets = require('xsockets.net');
var conn = new xsockets.TcpClient('192.168.254.182', 8080, ['sensor']);
var sensor = c.controller('sensor');
sensor.onopen = function() {
//Start sending sensor data
console.log('READY TO SEND DATA');
};
c.open();
Home
##Pre-Req
Software
Hardware
##Protocols
XMPP
AMQP
MQTT
WebSockets
Custom
##Raspberry Pi
Connecting
Configuration
WiFi
Update
###BLE
About
Support
GAP
Broadcast Topology
Connected Topology
GATT
Install
Configure
Connect
Read/Write
###NODEJS
Install
Install
Test
##XSockets
###Hosting
Self-hosted
Configuration
Azure worker role
###Let's build a location based chat
Chat controller
Add name & location
Target specific clients
Install
Test
###Sensor Controller
Basic
Adding state
Broadcast to all
Target specific clients
Confirm enable/disable
Complete
###Monitor Controller
Basic
OnOpened
Adding state
Turn sensor on/off
Complete
###Testing With Putty
Custom protocol
Connecting
Impersonate sensor
Impersonate monitor
###Scale Out
Azure Service Bus
##Suggested Clients
Overview
Web JavaScript
Putty
C-Sharp
TCP-IP
###MQTT
client
publish
##Azure
Hosting & scaling
##Links/Resources
Adafruit
Wikipedia