Академический Документы
Профессиональный Документы
Культура Документы
Aaron Bartell
Director of IBM i Innovation
albartell@krengeltech.com
Copyright 2015 Aaron Bartell
This session brought to you by...
What is Watson?
WebSockets is actually NOT HTTP, it just starts out at HTTP and then changes (aka
"upgrades") the connection to WebSockets.
Uses socket descriptors to retain state. IBM i has max of 2.5 million descriptors per job
(wowza!)
bit.ly/SO-websocket-connections
why?
Low latency
docs.google.com
before websockets...
bit.ly/pubnub-longpolling
high level
Response
HTTP/1.1 101 Switching Protocols Success!
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: iXFYxLieDcAue5MC56SsA3qX8zE=
Sec-WebSocket-Extensions: permessage-deflate
websocket frames
bit.ly/mozilla-websocket-server-frames
events
connection.onopen = function(e) {
console.log("Connected");
};
connection.onmessage = function(e) {
console.log( "Received: " + e.data);
};
connection.onclose = function(e) {
console.log("Connection closed");
};
bit.ly/SO-websocket-connections
cross-domain
bit.ly/SO-websocket-connections
browser-based dev tools
cloud9
ungit
These are
running on IBM i!
ibm i chat
- Runs on IBM i
- Written in Node.js
- Uses HTML5's WebSockets to communicate
- socket.io library used for client and server
- Article: bit.ly/nodejs-is-genius-with-websockets
app.js
io.on('connection', function(server){
server.on('disconnect', function(){
console.log('user disconnected');
});
server.on('chat_msg', function(msg){
io.emit('chat_msg', msg);
});
});
http.listen(8001, function(){
console.log('listening on *:8001');
});
index.html
<html>
<body>
<ul id="messages"></ul>
<form action="">
<input id="m" autocomplete="off" /><button>Send</button>
</form>
<script src="/socket.io/socket.io.js"></script>
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
<script>
var client = io();
$('form').submit(function(){
client.emit('chat_msg', $('#m').val());
$('#m').val('');
return false;
});
client.on('chat_msg', function(msg){
$('#messages').append($('<li>').text(msg));
});
</script>
</body>
</html>
Cognitive computing is the simulation of human thought processes in
a computerized model. Cognitive computing involves self-learning Tone
systems that use data mining, pattern recognition and natural Analyzer
language processing to mimic the way the human brain works.
Document
Conversion
Alchemy
Data News
Speech Visual
To Text Recognition
bit.ly/watson-services-catalog
Language
Translation
bit.ly/ibmi-nodejs-watson - "How To" MCPress Article
install
git clone copies source to
the IFS from github.com
$ pwd
/home/aaron/git
$ git clone git@github.com:watson-developer-cloud/speech-to-text-nodejs.git
Cloning into 'speech-to-text-nodejs'...
remote: Counting objects: 1340, done.
Receiving objects: 95% (1273/remote: Total 1340 (delta 0)
Receiving objects: 100% (1340/1340), 7.09 MiB | 474.00 KiB/s, done.
Resolving deltas: 100% (878/878), done.
Checking connectivity... done.
Checking out files: 100% (122/122), done. npm install looks at the
$ cd speech-to-text-nodejs package.json file and installs
$ npm install dependencies from npmjs.com.
$ npm run build
github.com/watson-developer-cloud/speech-to-text-nodejs
configure 4
2
1
bit.ly/watson-speech-to-text-docs
stats (continued)
setInterval( function() {
var sql = "SELECT JOB_NAME, AUTHORIZATION_NAME, " +
" ELAPSED_TOTAL_DISK_IO_COUNT, " +
" ELAPSED_CPU_PERCENTAGE " +
" FROM TABLE(QSYS2.ACTIVE_JOB_INFO()) X" +
" ORDER BY ELAPSED_CPU_PERCENTAGE DESC" +
" FETCH FIRST 20 ROWS ONLY"
db.exec(sql, function(results) {
io.emit('wrkactjob_update', results);
})
}, 2000);
wrkactjob.jade
table(id='jobs' class='table table-striped table-hover table-condensed')
thead
tr
th Job
th User
th Disk I/O
th CPU
tbody
script.
var client = io();
client.on('wrkactjob_update', function (data) {
});
We Have
Reached
The End!
Now...Get Engaged!
1. Visit litmis.com regularly for new content
2. Follow @litmisteam on Twitter
3. Contact me directly for assistance jump-
starting any open source development
projects on IBM i at
abartell@krengeltech.com