Skip to content

Commit

Permalink
Merge pull request #72 from getbraincloud/release/3.10
Browse files Browse the repository at this point in the history
Release/3.10
  • Loading branch information
davidstl authored Dec 5, 2018
2 parents 0ac01e5 + 967a7bd commit 7901da5
Show file tree
Hide file tree
Showing 21 changed files with 495 additions and 457 deletions.
32 changes: 32 additions & 0 deletions autobuild/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

set -e

pushd ../src
cat `ls *.js` > ../deploy/node/lib/brainCloudClient.concat.js
popd

pushd ../deploy/node/lib
echo "exports.BrainCloudWrapper = BrainCloudWrapper" >>brainCloudClient.concat.js
echo "exports.BrainCloudClient = BrainCloudClient" >>brainCloudClient.concat.js
popd

pushd ../deploy/node
npm install
popd

# Compile to make sure its all fine and ES5 worthy
java -jar ../tools/closure/compiler.jar --js ../deploy/node/lib/brainCloudClient.concat.js --js_output_file ../deploy/node/lib/brainCloudClient.min.js

pushd ../test
echo "serverUrl=https://internal.braincloudservers.com/dispatcherv2" >ids.txt
echo "appId=20001" >>ids.txt
echo "secret=4e51b45c-030e-4f21-8457-dc53c9a0ed5f" >>ids.txt
echo "version=1.0.0" >>ids.txt
echo "childAppId=20005" >>ids.txt
echo "childSecret=f8cec1cf-2f95-4989-910c-8caf598f83db" >>ids.txt
echo "parentLevelName=Master" >>ids.txt
echo "peerName=peerapp" >>ids.txt
npm install
node test
popd
21 changes: 3 additions & 18 deletions deploy/node/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
# brainCloud NodeJS client


## Install

```
npm i braincloud-node
```
or if still in development

```
npm i git+ssh://git@bitbucket.org:bitheadsinc/braincloud-node.git
```

## Usage

```javascript
var bc = require("braincloud-node")
var bc = require("braincloud")

function authenticated(response) {
console.log("Did get Authenticated to profileId:" + response.data.profileId);
Expand All @@ -24,8 +12,6 @@ function authenticated(response) {
_bc.brainCloudClient.file.prepareFileUpload("tests","dummyFile",shareable,replaceIfExists,)
}
_bc = new bc.BrainCloudWrapper("_mainWrapper");
// This Node implementation does not use jQuery so turn it off.
_bc.brainCloudManager.useJQuery(false);

secret = "aaaaaaaa-bbbb-0000-cccc-111111111111";
appId = "00000";
Expand All @@ -41,7 +27,7 @@ _bc.authenticateAnonymous(authenticated);

### File Upload

The file upload works slightly different in this implementation. Instead of using **XMLHttpRequest** you need to use **XMLHttpRequest4Upload**. Also the file object passed into *uploadFile* call needs to be a Read Stream from the nodes fs module.
The file upload works slightly different in this implementation if not used in the web. Instead of using **XMLHttpRequest** you need to use **XMLHttpRequest4Upload**. Also the file object passed into *uploadFile* call needs to be a Read Stream from the nodes fs module.

```javascript
var fs = require("fs")
Expand All @@ -62,9 +48,8 @@ _bc.brainCloudClient.file.prepareFileUpload("test2", fileName, shareable, replac
}
...
```
Only load and error listeners are triggered in this implementations.
Only `load` and `error` listeners are triggered in this implementations.
### Sessions
Sessions are not maintained across executions of scripts. i.e. Each script must initialy login.
88 changes: 31 additions & 57 deletions deploy/node/index.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,35 @@
window = {"navigator": {"userLanguage":"en"}};
CryptoJS = {};
window.FormData = require('form-data');
FormData = window.FormData;

var bc = require("./lib/brainCloudClient.concat.js")
if (typeof localStorage === "undefined" || localStorage === null) {
var LocalStorage = require('node-localstorage').LocalStorage;
os = require('os');
const configDir = os.homedir() + "/.bciot";
localStorage = new LocalStorage(configDir);
}
window.XMLHttpRequest = require("xmlhttprequest-ssl").XMLHttpRequest;
XMLHttpRequest = window.XMLHttpRequest;

XMLHttpRequest.UNSENT = 0;
XMLHttpRequest.OPENED = 1;
XMLHttpRequest.HEADERS_RECEIVED = 2;
XMLHttpRequest.LOADING = 3;
XMLHttpRequest.DONE = 4;

// XMLHttpRequest4Upload = require('./xmlHttpRequest4Upload.js');
// class XMLHttpRequest4Upload {
// constructor() {
// this.upload = {
// addEventListener : this.addEventListener.bind(this)
// };
// this.observer = {
// load:null,
// error:null,
// abort:null,
// progress:null
// }
// }
// open ( method, url, async) {
// this.url = url;
// this.method = method;
// this.async = async;
// }
// send ( form ) {
// var request = form.submit(this.url, function(err, res) {
// if (err) {
// this.observer["error"](err);
// } else {
// this.observer["load"](res);
// }
// res.resume();
// }.bind(this));
// // console.log(" Request is " + request );
// }

// addEventListener (event,callback) {
// this.observer[event] = callback
// }
// }

CryptoJS.MD5 = require('md5');
function XMLHttpRequest4Upload() {
this.upload = {
addEventListener : this.addEventListener.bind(this)
};
this.observer = {
load:null,
error:null,
abort:null,
progress:null
}
}
XMLHttpRequest4Upload.prototype.open = function(method, url, async) {
this.url = url;
this.method = method;
this.async = async;
}
XMLHttpRequest4Upload.prototype.send = function(form) {
form.submit(this.url, function(err, res) {
if (err) {
this.observer["error"](err);
} else {
this.observer["load"](res);
}
res.resume();
}.bind(this));
}
XMLHttpRequest4Upload.prototype.addEventListener = function(event,callback) {
this.observer[event] = callback
}

exports.XMLHttpRequest4Upload = require('./lib/xmlHttpRequest4Upload.js').XMLHttpRequest4Upload;
exports.XMLHttpRequest4Upload = XMLHttpRequest4Upload;
exports.BrainCloudWrapper = bc.BrainCloudWrapper
exports.BrainCloudClient = bc.BrainCloudClient
exports.BrainCloudClient = bc.BrainCloudClient
1 change: 1 addition & 0 deletions deploy/node/lib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Generated lib files are dumped here.
43 changes: 32 additions & 11 deletions deploy/node/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions deploy/node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "braincloud-node",
"version": "3.9.3",
"name": "braincloud",
"version": "3.10.0",
"description": " brainCloud client for NodeJS",
"main": "index.js",
"directories": {
Expand All @@ -23,10 +23,11 @@
"license": "Apache-2.0",
"dependencies": {
"form-data": "^2.3.2",
"isomorphic-ws": "^4.0.1",
"get-user-locale": "^1.1.1",
"md5": "^2.2.1",
"node-localstorage": "^1.3.1",
"xmlhttprequest-ssl": "^1.5.5"
"ws": "^6.1.2",
"xmlhttprequest": "^1.8.0"
},
"homepage": "https://portal.braincloudservers.com",
"files": [
Expand Down
3 changes: 0 additions & 3 deletions deploy/react/.gitignore

This file was deleted.

40 changes: 0 additions & 40 deletions deploy/react/README.md

This file was deleted.

12 changes: 0 additions & 12 deletions deploy/react/index.js

This file was deleted.

Loading

0 comments on commit 7901da5

Please sign in to comment.