Skip to content

Commit

Permalink
fix bug in weapp (#913)
Browse files Browse the repository at this point in the history
* add support for Ali Mini Program

* remove test for wx and ali Mini Program

* refactor lib/connect/ali.js

* rewrite wx.js

* fix wx.js

* remove unuse console, and fix connect/index.js for alis

* revert ws.js

* fix ali.js

* remove weapp-test script in package.json

* fix README.md

* fix ali.js to adapt IDE

* fix ali.js and wx.js

* fix wx.js

* fix: change let to var
  • Loading branch information
SyMind authored and mcollina committed Feb 2, 2019
1 parent 0379bf5 commit 8c9dffe
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/connect/ali.js
Expand Up @@ -14,7 +14,7 @@ function buildProxy () {
var proxy = new Transform()
proxy._write = function (chunk, encoding, next) {
my.sendSocketMessage({
data: chunk,
data: chunk.buffer,
success: function () {
next()
},
Expand Down
25 changes: 23 additions & 2 deletions lib/connect/wx.js
Expand Up @@ -12,7 +12,7 @@ function buildProxy () {
var proxy = new Transform()
proxy._write = function (chunk, encoding, next) {
socketTask.send({
data: chunk,
data: chunk.buffer,
success: function () {
next()
},
Expand Down Expand Up @@ -78,7 +78,7 @@ function bindEventHandler () {
})

socketTask.onError(function (res) {
stream.destroy(res)
stream.destroy(new Error(res.errMsg))
})
}

Expand All @@ -104,6 +104,27 @@ function buildStream (client, opts) {

proxy = buildProxy()
stream = duplexify.obj()
stream._destroy = function (err, cb) {
socketTask.close({
success: function () {
cb && cb(err)
}
})
}

var destroyRef = stream.destroy
stream.destroy = function () {
stream.destroy = destroyRef

var self = this
process.nextTick(function () {
socketTask.close({
fail: function () {
self._destroy(new Error())
}
})
})
}.bind(stream)

bindEventHandler()

Expand Down

0 comments on commit 8c9dffe

Please sign in to comment.