Skip to content

Commit

Permalink
Fixes bug with sending multiple messages, adding a new test for this …
Browse files Browse the repository at this point in the history
…scenario.

Cleanup of server comment and client build dependency.
  • Loading branch information
schwink committed Dec 23, 2010
1 parent e64570b commit 7658498
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -6,6 +6,7 @@
ebin/
tbin/
doc/
out/

# Test output
_test/
Expand Down
4 changes: 2 additions & 2 deletions client/web/debian/control
Expand Up @@ -2,9 +2,9 @@ Source: kanaloa-client-web
Section: web
Priority: extra
Maintainer: Steve <steve@schwink.net>
Build-Depends: debhelper (>= 7), devscripts
Build-Depends: debhelper (>= 7), devscripts, jsdoc-toolkit, yuicompressor
Standards-Version: 3.8.1
Homepage:
Homepage: http://schwink.net/kanaloa

Package: kanaloa-client-web
Architecture: any
Expand Down
2 changes: 1 addition & 1 deletion client/web/src/kanaloa.js
Expand Up @@ -331,7 +331,7 @@ _KanaloaHttpSendBatcher.prototype._sendPost = function() {
post.sentCount = 0;
}

connection._post = null;
batcher._post = null;

// Loop to pick up accumulated messages.
if (connection._bumpOutgoing(statusCode)) {
Expand Down
24 changes: 24 additions & 0 deletions client/web/test/integration/index.js
Expand Up @@ -39,6 +39,30 @@ $(document).ready(function(){
connection.send(message);
});

asyncTest("chained message send and receive (onMessageReceived send)", 1, function() {
function newMessage() {
return "test message " + (new Date()).getTime();
}

var connection = new KanaloaConnection(server);
var counter = 0;

connection.onDataReceived = function(data) {
counter++;

if (counter == 1) {
connection.send(newMessage());
}
else {
connection.disconnect();
equals(2, counter, "received both messages");
start();
}
};

connection.send(newMessage());
});

asyncTest("server disconnect handling", 1, function() {
var connection = new KanaloaConnection(server);

Expand Down
4 changes: 2 additions & 2 deletions server/dev-service/src/test_app.erl
Expand Up @@ -17,14 +17,14 @@ ensure_started(App) ->
end.

%% @spec start() -> ok
%% @doc Start the thruster_mochiweb server.
%% @doc Start the server.
start() ->
io:format("test_app:start/0 called\n", []),
ensure_started(crypto),
application:start(test_app).

%% @spec stop() -> ok
%% @doc Stop the thruster_mochiweb server.
%% @doc Stop the server.
stop() ->
Res = application:stop(test_app),
application:stop(crypto),
Expand Down

0 comments on commit 7658498

Please sign in to comment.