Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.6.7 proposal #101

Merged
merged 19 commits into from
Mar 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ node_modules
*.heapsnapshot

# Development helpers
crlf.js
dev/

# Project files
Expand Down
5 changes: 5 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Alexey Orlenko <eaglexrlnk@gmail.com>
Dmitry Borisov <dimon.durak@gmail.com> <Dimon Durak>
Mykola Bilochub <nbelochub@gmail.com>
Timur Shemsedinov <timur.shemsedinov@gmail.com>
Vlad Dziuba <dzyubavlad@gmail.com> <Dzyubavlad@gmail.com>
5 changes: 3 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*.heapsnapshot

# Development helpers
crlf.js
dev/

# Project files
Expand All @@ -14,8 +13,10 @@ dev/
# node-gyp build
build/

# Built docs
# Docs
doc/
site/
mkdocs.yml

# Python bytecode
*.pyc
Expand Down
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ node_js:
- "6.7"
- "6.8"
- "6.9"
- "6.10"
- "7.0"
- "7.1"
- "7.2"
- "7.3"
- "7.4"
- "7.5"
- "7.6"
- "7.7"
env:
- CXX=g++-6
addons:
Expand Down
3 changes: 3 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Timur Shemsedinov <timur.shemsedinov@gmail.com>
Dmitry Borisov <dimon.durak@gmail.com>
Artem Chernenkiy <notthewhite@gmail.com>
Alexey Orlenko <eaglexrlnk@gmail.com>
Mykola Bilochub <nbelochub@gmail.com>
Vlad Dziuba <dzyubavlad@gmail.com>
74 changes: 73 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,78 @@
# `metarhia-jstp` changelog

## Version 0.6.7 (2017-03-14, @aqrln)

This is a bugfix release.

Notable changes:

* **lib:** make failed addon loading more informative
*(Alexey Orlenko)*
[#90](https://github.com/metarhia/JSTP/pull/90)
* **w3c-ws:** emit missing error event
*(Alexey Orlenko)*
[#93](https://github.com/metarhia/JSTP/pull/93)
* **w3c-ws:** fix invalid property access
*(Alexey Orlenko)*
[#94](https://github.com/metarhia/JSTP/pull/94)
* **connection:** check that method arguments exist
*(Alexey Orlenko)*
[#100](https://github.com/metarhia/JSTP/pull/100)

All changes:

* **doc:** fix linter warning in CHANGELOG.md
*(Alexey Orlenko)*
[#80](https://github.com/metarhia/JSTP/pull/80)
* **tools:** remove crlf.js from dot-ignore files
*(Alexey Orlenko)*
[#83](https://github.com/metarhia/JSTP/pull/83)
* **npm:** don't include doc/ and mkdocs.yml to package
*(Alexey Orlenko)*
[#82](https://github.com/metarhia/JSTP/pull/82)
* **doc:** add session WG meeting
*(Mykola Bilochub)*
[#81](https://github.com/metarhia/JSTP/pull/81)
* **lint:** update remark
*(Alexey Orlenko)*
[#87](https://github.com/metarhia/JSTP/pull/87)
* **test:** add Node.js 6.10 and 7.6 to .travis.yml
*(Alexey Orlenko)*
[#86](https://github.com/metarhia/JSTP/pull/86)
* **tools:** move build-native.js to tools
*(Alexey Orlenko)*
[#89](https://github.com/metarhia/JSTP/pull/89)
* **lib:** make failed addon loading more informative
*(Alexey Orlenko)*
[#90](https://github.com/metarhia/JSTP/pull/90)
* **w3c-ws:** emit missing error event
*(Alexey Orlenko)*
[#93](https://github.com/metarhia/JSTP/pull/93)
* **w3c-ws:** fix invalid property access
*(Alexey Orlenko)*
[#94](https://github.com/metarhia/JSTP/pull/94)
* **test:** add Node.js 7.7 to .travis.yml
*(Alexey Orlenko)*
[#95](https://github.com/metarhia/JSTP/pull/95)
* **connection:** change style of a forward declaration
*(Alexey Orlenko)*
[#96](https://github.com/metarhia/JSTP/pull/96)
* **lib:** change multiline function signatures style
*(Alexey Orlenko)*
[#97](https://github.com/metarhia/JSTP/pull/97)
* **tools:** generate authors list automatically
*(Alexey Orlenko)*
[#88](https://github.com/metarhia/JSTP/pull/88)
* **meta:** update AUTHORS and .mailmap
*(Alexey Orlenko)*
[#88](https://github.com/metarhia/JSTP/pull/88)
* **meta:** fix misleading language in LICENSE
*(Alexey Orlenko)*
[#88](https://github.com/metarhia/JSTP/pull/88)
* **connection:** check that method arguments exist
*(Alexey Orlenko)*
[#100](https://github.com/metarhia/JSTP/pull/100)

## Version 0.6.6 (2017-02-20, @aqrln)

This is mostly a bugfix release. Additionally, parser performance is improved.
Expand Down Expand Up @@ -28,7 +101,6 @@ Notable changes:
*(Alexey Orlenko)*
[#78](https://github.com/metarhia/JSTP/pull/78)


All changes:

* **server:** clean internal structures on close
Expand Down
5 changes: 2 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ JavaScript Transfer Protocol ("JSTP") is licensed for use as follows:
"""
MIT License

Copyright (c) 2016–2017 JSTP project authors
(see https://github.com/metarhia/JSTP/blob/master/AUTHORS for full list)
and other JSTP contributors.
Copyright (c) 2016–2017 JSTP contributors
(see https://github.com/metarhia/JSTP/blob/master/AUTHORS).

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
65 changes: 65 additions & 0 deletions doc/meetings/2017-02-21-sessions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Sessions WG meeting

Date: 2017-02-21

### Invited:

* Alexey Orlenko &lt;eaglexrlnk@gmail.com&gt;
([@aqrln](https://github.com/aqrln)) from server team
* Mykola Bilochub &lt;nbelochub@gmail.com&gt;
([@belochub](https://github.com/belochub)) from server team
* Denys Otrishko &lt;shishugi@gmail.com&gt;
([@lundibundi](https://github.com/lundibundi)) from Android team
* Andrew Vysotskyi &lt;firemaaaan@gmail.com&gt;
([@Gagnant](https://github.com/Gagnant)) from iOS team

### Present:

* Alexey Orlenko &lt;eaglexrlnk@gmail.com&gt;
([@aqrln](https://github.com/aqrln)) from server team
* Mykola Bilochub &lt;nbelochub@gmail.com&gt;
([@belochub](https://github.com/belochub)) from server team
* Denys Otrishko &lt;shishugi@gmail.com&gt;
([@lundibundi](https://github.com/lundibundi)) from Android team

### Agenda:

* General way of reconnection to existing sessions;
* Session restoration mechanisms architecture;
* The problems with reconnection mobile developers encountered in our last
project and proper ways to solve them;
* Handshake packet formats (for request and response) that will be used to
implement reconnection to existing sessions.

### Conclusions:

* To make packet numbers unique for every session, not connection like it was before;
* To send total count of packets sent and received by each side during the session
in handshake packet, like this:

```javascript
{ handshake: [0, 'appName'], session: ['sessionId', sent_count, received_count] }
```

and answer

```javascript
{ handshake: [0], ok: [sent_count, received_count] }
```

### Post-discussion additions:

1. Even though packet IDs are incremented throughout the session, not the
connection, handshake packets are always 0 since we don't know which packet
IDs to use until a handshake has been performed. After that, the order
continues as it should have been if there hadn't been reconnection, with an
extra handshake being transparent.

2. The standard `ERR_AUTH_FAILED` error will be used for any handshake
authentication strategy, regardless of it being `login`, `session` or
anything we may probably add later. What it means for session restoration
handshakes is that if session ID is invalid, the server responds with

```javascript
{ handshake: [0], error: [11] }
```
6 changes: 1 addition & 5 deletions lib/applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ apps.Application = Application;
// callback - method callback
//
Application.prototype.callMethod = function(
connection,
interfaceName,
methodName,
args,
callback
connection, interfaceName, methodName, args, callback
) {
const appInterface = this.api[interfaceName];
if (!appInterface) {
Expand Down
11 changes: 2 additions & 9 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ Client.prototype.disconnect = function(callback) {
// callback - callback function with signature (error, connection, sessionId)
//
Client.prototype.connectAndHandshake = function(
appName,
username,
password,
callback
appName, username, password, callback
) {
this.connect((error, connection) => {
if (error) {
Expand Down Expand Up @@ -107,11 +104,7 @@ Client.prototype.connectAndHandshake = function(
// (error, connection, sessionId, api)
//
Client.prototype.connectAndInspect = function(
appName,
username,
password,
interfaces,
callback
appName, username, password, interfaces, callback
) {
this.connectAndHandshake(
appName, username, password, (error, connection, sid) => {
Expand Down
1 change: 1 addition & 0 deletions lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ common.safeRequire = (moduleName) => {
try {
return require(moduleName);
} catch (err) {
console.warn(err.toString());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In future we will redirect this to logging provider. Just don't forget. Better create issue :)
For example in Impress to application.log.warning, if no provider then print to stdout.

Copy link
Member Author

@aqrln aqrln Mar 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better create issue :)

Done :)
#102

return null;
}
};
Expand Down
19 changes: 8 additions & 11 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let nextConnectionId = 0;
// Mapping of packet types to handler function names (forward declaration, see
// definition below the Connection class).
//
let PACKET_HANDLERS; // eslint-disable-line prefer-const
let PACKET_HANDLERS = null;

// JSTP connection class
// transport - an abstract socket
Expand Down Expand Up @@ -73,10 +73,7 @@ util.inherits(Connection, events.EventEmitter);
// has been received
//
Connection.prototype.callMethod = function(
interfaceName,
methodName,
args,
callback
interfaceName, methodName, args, callback
) {
const packet = this.createPacket('call', interfaceName, methodName, args);
const packetId = packet.call[0];
Expand Down Expand Up @@ -110,9 +107,7 @@ Connection.prototype.callback = function(packetId, error, result) {
// args - event arguments as an object
//
Connection.prototype.emitRemoteEvent = function(
interfaceName,
eventName,
args
interfaceName, eventName, args
) {
const packet = this.createPacket('event', interfaceName, eventName, args);
this._send(packet);
Expand Down Expand Up @@ -478,6 +473,10 @@ Connection.prototype._processCallPacket = function(packet, keys) {

const callback = this._remoteCallbackWrapper.bind(this, packetId);

if (!args) {
return callback(errors.ERR_INVALID_SIGNATURE);
}

try {
this.application.callMethod(this,
interfaceName, methodName, args, callback);
Expand Down Expand Up @@ -591,9 +590,7 @@ Connection.prototype._processPongPacket = function(packet) {
// result - data to send back as a result
//
Connection.prototype._remoteCallbackWrapper = function(
packetId,
error,
...result
packetId, error, ...result
) {
this.callback(packetId, error, result);
};
Expand Down
4 changes: 2 additions & 2 deletions lib/record-serialization.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ if (jstpNative) {
}
} else {
console.warn(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also should be redirected to logging provider

'JSTP native addon is not built. ' +
'JSTP native addon is not built or is not functional. ' +
'Run `npm install` in order to build it, otherwise you will get ' +
'poor server performance under load.'
'poor performance.'
);
module.exports = require('./record-serialization-fallback');
}
5 changes: 2 additions & 3 deletions lib/transport.ws.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ W3CWebSocketClient.prototype.connect = function(callback) {
if (callback) {
callback(error);
}
this.emit('error', error);
return;
}

Expand Down Expand Up @@ -82,11 +83,9 @@ W3CWebSocketClient.prototype.connect = function(callback) {
//
W3CWebSocketClient.prototype.disconnect = function(callback) {
transportCommon.ensureClientConnected(this);

if (callback) {
this.connection.once('close', callback);
this.socketEventEmitter.once('close', callback);
}

this.socket.close();
};

Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "metarhia-jstp",
"version": "0.6.6",
"version": "0.6.7",
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>",
"description": "JavaScript Transfer Protocol for Impress Application Server",
"license": "MIT",
Expand Down Expand Up @@ -49,9 +49,9 @@
"karma-safari-launcher": "^1.0.0",
"karma-webpack": "^2.0.1",
"mocha": "^3.2.0",
"remark-cli": "^2.1.0",
"remark-lint": "^5.4.0",
"remark-validate-links": "^5.0.0",
"remark-cli": "^3.0.0",
"remark-lint": "^6.0.0",
"remark-validate-links": "^6.0.0",
"webpack": "^2.2.1"
},
"scripts": {
Expand All @@ -64,8 +64,8 @@
"lint": "eslint . && remark .",
"install": "npm run rebuild-node",
"build": "npm run build-node && npm run build-browser",
"build-node": "node build-native",
"rebuild-node": "node build-native --rebuild",
"build-node": "node tools/build-native",
"rebuild-node": "node tools/build-native --rebuild",
"build-browser": "webpack --progress --colors",
"prepublish": "npm run build-browser",
"pretest": "npm run build-node"
Expand Down
2 changes: 2 additions & 0 deletions build-native.js → tools/build-native.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env node

'use strict';

const fs = require('fs');
Expand Down
Loading