Skip to content

Commit

Permalink
Merge pull request #201 from tomvantilburg/master
Browse files Browse the repository at this point in the history
merge from Tom
  • Loading branch information
tomvantilburg committed Aug 11, 2015
2 parents 3091e4c + 7cced07 commit 2699b69
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 13 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cow",
"version": "2.2.0-beta1",
"version": "2.2.0-beta2",
"homepage": "https://github.com/Geodan/cow",
"description": "Release for Eagle water",
"authors": [
Expand Down
18 changes: 16 additions & 2 deletions dist/cow.js
Original file line number Diff line number Diff line change
Expand Up @@ -2357,6 +2357,20 @@ function lzw_decode(s) {
}
return out.join("");
}
function encode_utf8(s) {
return unescape(encodeURIComponent(s));
}

function decode_utf8(s) {
try{
return decodeURIComponent(escape(s));
}
catch(e){
console.warn(e,s);
debugger;
}
}


(function(){

Expand Down Expand Up @@ -2432,7 +2446,7 @@ Cow.messenger.prototype.sendData = function(data, action, target){
message.action = action;
//message.payload = data;
//TT: newly added lzw compression in 2.2.0. This breaks COW versions!
message.payload = lzw_encode(JSON.stringify(data));
message.payload = lzw_encode(encode_utf8(JSON.stringify(data)));
var stringified;
var endcoded;
try {
Expand All @@ -2456,7 +2470,7 @@ Cow.messenger.prototype._onMessage = function(message){
var payload = data.payload;
}
else {
var payload = JSON.parse(lzw_decode(data.payload));
var payload = JSON.parse(decode_utf8(lzw_decode(data.payload)));
}
var target = data.target;
if (sender != PEERID){
Expand Down
5 changes: 2 additions & 3 deletions dist/cow.min.js

Large diffs are not rendered by default.

18 changes: 16 additions & 2 deletions dist/cow.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -2282,6 +2282,20 @@ function lzw_decode(s) {
}
return out.join("");
}
function encode_utf8(s) {
return unescape(encodeURIComponent(s));
}

function decode_utf8(s) {
try{
return decodeURIComponent(escape(s));
}
catch(e){
console.warn(e,s);
debugger;
}
}


(function(){

Expand Down Expand Up @@ -2357,7 +2371,7 @@ Cow.messenger.prototype.sendData = function(data, action, target){
message.action = action;
//message.payload = data;
//TT: newly added lzw compression in 2.2.0. This breaks COW versions!
message.payload = lzw_encode(JSON.stringify(data));
message.payload = lzw_encode(encode_utf8(JSON.stringify(data)));
var stringified;
var endcoded;
try {
Expand All @@ -2381,7 +2395,7 @@ Cow.messenger.prototype._onMessage = function(message){
var payload = data.payload;
}
else {
var payload = JSON.parse(lzw_decode(data.payload));
var payload = JSON.parse(decode_utf8(lzw_decode(data.payload)));
}
var target = data.target;
if (sender != PEERID){
Expand Down
4 changes: 2 additions & 2 deletions dist/cow.node.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/cow2.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Cow.core = function(config){
if (typeof(config) == 'undefined' ) {
config = {};
}
this._version = '2.2.0-beta1';
this._version = '2.2.0-beta2';
this._herdname = config.herdname || 'cow';
this._userid = null;
this._socketserverid = null;
Expand Down
18 changes: 16 additions & 2 deletions src/cow2.messenger.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ function lzw_decode(s) {
}
return out.join("");
}
function encode_utf8(s) {
return unescape(encodeURIComponent(s));
}

function decode_utf8(s) {
try{
return decodeURIComponent(escape(s));
}
catch(e){
console.warn(e,s);
debugger;
}
}


(function(){

Expand Down Expand Up @@ -129,7 +143,7 @@ Cow.messenger.prototype.sendData = function(data, action, target){
message.action = action;
//message.payload = data;
//TT: newly added lzw compression in 2.2.0. This breaks COW versions!
message.payload = lzw_encode(JSON.stringify(data));
message.payload = lzw_encode(encode_utf8(JSON.stringify(data)));
var stringified;
var endcoded;
try {
Expand All @@ -153,7 +167,7 @@ Cow.messenger.prototype._onMessage = function(message){
var payload = data.payload;
}
else {
var payload = JSON.parse(lzw_decode(data.payload));
var payload = JSON.parse(decode_utf8(lzw_decode(data.payload)));
}
var target = data.target;
if (sender != PEERID){
Expand Down

0 comments on commit 2699b69

Please sign in to comment.