compiled/
*.o
*~
+/src/js/iotjs/node_modules/
+node_modules/
+dist/
+bower_components
+test/bower_components
static final int HMAC_SIZE=32;
/** Sequence number of the slot. */
- private long seqnum;
+ private long seqnum;//
/** HMAC of previous slot. */
private byte[] prevhmac;
/** HMAC of this slot. */
--- /dev/null
+{ "presets": ["es2015"] }
--- /dev/null
+{
+ "directory": "bower_components"
+}
\ No newline at end of file
--- /dev/null
+# http://editorconfig.org
+root = true
+
+[*]
+indent_style = space
+indent_size = 2
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+trim_trailing_whitespace = false
--- /dev/null
+{
+ "node": true,
+ "esnext": true,
+ "bitwise": true,
+ "camelcase": true,
+ "curly": true,
+ "eqeqeq": true,
+ "immed": true,
+ "indent": 2,
+ "latedef": true,
+ "newcap": true,
+ "noarg": true,
+ "quotmark": "single",
+ "regexp": true,
+ "undef": true,
+ "unused": true,
+ "trailing": true,
+ "smarttabs": true,
+ "white": true
+}
--- /dev/null
+iotjs
+==================================================
+
+What does your library do?
+
+Getting Started
+--------------------------------------
+
+- Install dependencies: `npm install`
+- Run `bower install` to install frontend dependencies
+- Run `gulp` to build your library
+
+Usage
+--------------------------------------
+
+How can I use it?
+
+Future Development
+--------------------------------------
+
+What would you like to do but don't have the time for?
--- /dev/null
+{
+ "name": "iotjs",
+ "version": "0.0.0",
+ "dependencies": {}
+}
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>iotjs Example</title>
+</head>
+<body>
+
+<script src="../build/iotjs.js"></script>
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+var gulp = require('gulp');
+var gulpif = require('gulp-if');
+var clean = require('gulp-clean');
+var order = require('gulp-order');
+var rename = require('gulp-rename');
+var concat = require('gulp-concat');
+var jshint = require('gulp-jshint');
+var uglify = require('gulp-uglify');
+var stylish = require('jshint-stylish');
+var livereload = require('gulp-livereload');
+var sourcemaps = require('gulp-sourcemaps');
+var flags = require('minimist')(process.argv.slice(2));
+
+// Gulp command line arguments
+var production = flags.production || false;
+var debug = flags.debug || !production;
+var watch = flags.watch;
+
+gulp.task('build', ['clean'], function() {
+ // Single entry point to browserify
+ gulp.src(['src/*.js', 'vendor/*.js'])
+ .pipe(order([ // The order of concatenation
+ 'src/main.js'
+ ], {base: '.'}))
+ .pipe(gulpif(debug, sourcemaps.init()))
+ .pipe(gulpif(production, uglify()))
+ .pipe(concat('iotjs.js'))
+ .pipe(gulpif(debug, sourcemaps.write()))
+ .pipe(gulp.dest('./build/'))
+ .pipe(gulpif(watch, livereload()));
+});
+
+gulp.task('lint', function() {
+ return gulp.src('src/*.js')
+ .pipe(jshint())
+ .pipe(jshint.reporter(stylish))
+});
+
+gulp.task('clean', function() {
+ return gulp.src(['./build'], {read: false})
+ .pipe(clean({force: true}));
+});
+
+gulp.task('watch', function() {
+ livereload.listen();
+ gulp.watch('src/*', ['lint', 'build']);
+});
+
+gulp.task('default', ['clean', 'lint', 'build']);
--- /dev/null
+class Entry{
+ constructor(slot) {
+ if (slot && slot instanceof Slot) {
+
+ this.TypeKeyValue = 1;
+ this.TypeLastmessage = 2;
+ this.TypeRejectedMessage = 3;
+ this.TypeTableStatus = 4;
+ this.liveStatus = true;
+ this.parentslot = slot;
+
+ }
+ }
+ static decode(slot, bytebuffer) {
+ if (slot instanceof Slot && bytebuffer instanceof ByteBuffer) {
+ var type = bytebuffer.readByte();
+ switch (type) {
+ case this.TypeKeyValue:
+ return KeyValue.decode(slot, bytebuffer);
+ case this.TypeLastmessage:
+ return LastMessage.decode(slot, bytebuffer);
+ case this.TypeRejectedMessage:
+ return RejectedMessage.decode(slot, bytebuffer);
+ case this.TypeTableStatus:
+ return TableStatus.decode(slot, bytebuffer);
+ default:
+ throw new Error("Unrecognized Entry Type: " + type);
+ }
+ }
+ }
+ isLive(){
+ return this.liveStatus;
+ }
+ setDead() {
+ this.liveStatus = false;
+ parentslot.decrementLiveCount();
+ }
+
+ //must be overriden.
+ encode(bytebuffer){
+
+ }
+ getSize(){
+
+ }
+ getType(){
+
+ }
+ getCopy(slot){
+ if(slot && slot instanceof Slot){
+
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+class Slot{
+ constructor(seqnum,machineid,prevhmac,hmac){
+ this.SLOT_SIZE=2048;
+ this.RESERVED_SPACE=64;
+ this.HMAC_SIZE=32;
+ (typeof seqnum === "number")? this.seqnum = seqnum : throw new Error("seqnum should be a number");
+ (typeof machineid === "number")? this.machineid = seqnum : throw new Error("seqnum should be a number");
+
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "iotjs",
+ "version": "0.0.0",
+ "scripts": {
+ "test": "gulp && node ./test/test.js"
+ },
+ "dependencies": {
+ "bytebuffer": "^5.0.1",
+ "crypto-js": "^3.1.6",
+ "gulp": "3.8.11",
+ "gulp-clean": "0.3.1",
+ "gulp-concat": "2.5.2",
+ "gulp-if": "1.2.5",
+ "gulp-jshint": "1.9.4",
+ "gulp-livereload": "3.8.0",
+ "gulp-load-plugins": "0.8.1",
+ "gulp-order": "1.1.1",
+ "gulp-rename": "1.2.0",
+ "gulp-sourcemaps": "1.5.1",
+ "gulp-uglify": "1.1.0",
+ "jshint-stylish": "1.0.1",
+ "minimist": "1.1.1",
+ "object-hash": "^1.1.3",
+ "request": "^2.74.0",
+ "underscore": "^1.8.3"
+ },
+ "devDependencies": {
+ "babel-cli": "^6.11.4",
+ "babel-preset-es2015": "^6.9.0",
+ "browserify": "^13.1.0"
+ }
+}
--- /dev/null
+"use strict";
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+var Entry = function () {
+ function Entry(slot) {
+ _classCallCheck(this, Entry);
+
+ if (slot && slot instanceof Slot) {
+
+ this.TypeKeyValue = 1;
+ this.TypeLastmessage = 2;
+ this.TypeRejectedMessage = 3;
+ this.TypeTableStatus = 4;
+ this.liveStatus = true;
+ this.parentslot = slot;
+ }
+ }
+
+ _createClass(Entry, [{
+ key: "isLive",
+ value: function isLive() {
+ return this.liveStatus;
+ }
+ }, {
+ key: "setDead",
+ value: function setDead() {
+ this.liveStatus = false;
+ parentslot.decrementLiveCount();
+ }
+
+ //must be overriden.
+
+ }, {
+ key: "encode",
+ value: function encode(bytebuffer) {}
+ }, {
+ key: "getSize",
+ value: function getSize() {}
+ }, {
+ key: "getType",
+ value: function getType() {}
+ }, {
+ key: "getCopy",
+ value: function getCopy(slot) {
+ if (slot && slot instanceof Slot) {}
+ }
+ }], [{
+ key: "decode",
+ value: function decode(slot, bytebuffer) {
+ if (slot instanceof Slot && bytebuffer instanceof ByteBuffer) {
+ var type = bytebuffer.readByte();
+ switch (type) {
+ case this.TypeKeyValue:
+ return KeyValue.decode(slot, bytebuffer);
+ case this.TypeLastmessage:
+ return LastMessage.decode(slot, bytebuffer);
+ case this.TypeRejectedMessage:
+ return RejectedMessage.decode(slot, bytebuffer);
+ case this.TypeTableStatus:
+ return TableStatus.decode(slot, bytebuffer);
+ default:
+ throw new Error("Unrecognized Entry Type: " + type);
+ }
+ }
+ }
+ }]);
+
+ return Entry;
+}();
\ No newline at end of file
--- /dev/null
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+var IoTString = function () {
+ function IoTString(arg) {
+ _classCallCheck(this, IoTString);
+
+ if (arg === undefined) {
+ this.array = new Uint8Array();
+ this.hashcode;
+ } else if (arg && typeof arg === "string") {
+ this.array = new Uint8Array(arg.length);
+ for (var i = 0; i < arg.length; ++i) {
+ this.array[i] = arg.charCodeAt(i);
+ }
+ this.hashcode = hash(this.array);
+ } else if (arg && arg instanceof Uint8Array) {
+ this.array = arg;
+ this.hashcode = hashcode(arg);
+ }
+ }
+
+ _createClass(IoTString, [{
+ key: "shallow",
+ value: function shallow(arg) {
+ if (arg && arg instanceof Uint8Array) {
+ var i = new IotString(arg);
+ return i;
+ }
+ }
+ }, {
+ key: "internalBytes",
+ value: function internalBytes() {
+ return this.array;
+ }
+ }, {
+ key: "hashCode",
+ value: function hashCode() {
+ return this.hashcode;
+ }
+ }, {
+ key: "toString",
+ value: function toString() {
+ return this.array.toString();
+ }
+ }, {
+ key: "getBytes",
+ value: function getBytes() {
+ var obj;
+ return _.extend(obj, this.array);
+ }
+ }, {
+ key: "equals",
+ value: function equals(arr) {
+ return _.isEqual(arr, this.array);
+ }
+ }, {
+ key: "length",
+ value: function length() {
+ return this.array.length;
+ }
+ }]);
+
+ return IoTString;
+}();
\ No newline at end of file
--- /dev/null
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+var Liveness = function Liveness() {
+ _classCallCheck(this, Liveness);
+};
\ No newline at end of file
--- /dev/null
+/* jshint devel:true */
+"use strict";
+console.log('Welcome to iotjs-www','\n\n');
+
+// set up the base line..
+// Using browserify to set up browser exports
+var crypto = require('crypto-js');
+var hash = require('object-hash');
+var _ = require('underscore');
+var ByteBuffer = require("bytebuffer");
+
+
+(function() {
+
+ var root = this;
+
+
+ // iot namespace main constructor
+ var iot = function(obj) {
+ if (obj instanceof iot) return obj;
+ if (!(this instanceof iot)) return new iot(obj);
+ this.iot = obj;
+ };
+
+ // export iot to the global exports
+ if (typeof exports !== 'undefined') {
+ if (typeof module !== 'undefined' && module.exports) {
+ exports = module.exports = iot;
+ }
+ exports.iot = iot;
+ } else {
+ root.iot = iot;
+ }
+
+ iot.baselinetest = function(){
+ // baseline test
+ console.log('its alive!!!');
+ console.log();
+
+ //local hash test
+ console.log(hash('hello man'));
+ console.log(typeof hash('hello man'));
+ console.log();
+
+ //Pair test
+ var p = new Pair(1,2);
+ console.log(p.toString());
+ console.log();
+
+ //iotstring test
+ var i = new IoTString('hello');
+ console.log(i.length());
+ console.log();
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+}())
\ No newline at end of file
--- /dev/null
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+var Pair = function () {
+ function Pair(a, b) {
+ _classCallCheck(this, Pair);
+
+ this.a = a;
+ this.b = b;
+ }
+
+ _createClass(Pair, [{
+ key: 'getFirst',
+ value: function getFirst() {
+ return this.a;
+ }
+ }, {
+ key: 'getSecond',
+ value: function getSecond() {
+ return this.b;
+ }
+ }, {
+ key: 'toString',
+ value: function toString() {
+ var str = '<' + this.a + ',' + this.b + '>';
+ return str;
+ }
+ }]);
+
+ return Pair;
+}();
\ No newline at end of file
--- /dev/null
+var iot = require('../build/iotjs.js');
+
+iot.baselinetest();
+
+
+