Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
a5e9c930
W
wechaty
项目概览
.Veneno.
/
wechaty
与 Fork 源项目一致
Fork自
wechaty / wechaty
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
wechaty
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a5e9c930
编写于
8月 24, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix typo and show last feed when watchdog timeout
上级
3df7342e
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
43 addition
and
23 deletion
+43
-23
src/puppet-web/bridge.js
src/puppet-web/bridge.js
+6
-2
src/puppet-web/event.js
src/puppet-web/event.js
+2
-2
src/puppet-web/index.js
src/puppet-web/index.js
+5
-5
src/puppet-web/watchdog.js
src/puppet-web/watchdog.js
+8
-4
src/puppet.js
src/puppet.js
+6
-6
test/puppet.spec.js
test/puppet.spec.js
+13
-0
test/wechaty.spec.js
test/wechaty.spec.js
+3
-4
未找到文件。
src/puppet-web/bridge.js
浏览文件 @
a5e9c930
...
...
@@ -16,10 +16,14 @@ const log = require('../npmlog-env')
class
Bridge
{
constructor
(
options
)
{
if
(
!
options
||
!
options
.
puppet
)
{
throw
new
Error
(
'
Bridge need a puppet
'
)}
if
(
!
options
||
!
options
.
puppet
)
{
throw
new
Error
(
'
Bridge need a puppet
'
)
}
log
.
verbose
(
'
PuppetWebBridge
'
,
'
new Bridge({puppet: %s, port: %s})
'
,
options
.
puppet
.
constructor
.
name
,
options
.
port
)
,
options
.
port
)
this
.
puppet
=
options
.
puppet
this
.
port
=
options
.
port
||
8788
// W(87) X(88), ascii char code ;-]
...
...
src/puppet-web/event.js
浏览文件 @
a5e9c930
...
...
@@ -154,8 +154,8 @@ function onServerDisconnect(data) {
this
.
user
=
null
}
if
(
this
.
readyStat
us
()
===
'
disconnecting
'
)
{
log
.
verbose
(
'
PuppetWebEvent
'
,
'
onServerDisconnect() be called when readyStat
us
is `disconnecting`
'
)
if
(
this
.
readyStat
e
()
===
'
disconnecting
'
)
{
log
.
verbose
(
'
PuppetWebEvent
'
,
'
onServerDisconnect() be called when readyStat
e
is `disconnecting`
'
)
return
}
...
...
src/puppet-web/index.js
浏览文件 @
a5e9c930
...
...
@@ -89,12 +89,12 @@ class PuppetWeb extends Puppet {
quit
()
{
log
.
verbose
(
'
PuppetWeb
'
,
'
quit()
'
)
if
(
this
.
readyStat
us
()
===
'
disconnecting
'
)
{
log
.
warn
(
'
PuppetWeb
'
,
'
quit() is called but readyStat
us
is `disconnecting`?
'
)
if
(
this
.
readyStat
e
()
===
'
disconnecting
'
)
{
log
.
warn
(
'
PuppetWeb
'
,
'
quit() is called but readyStat
e
is `disconnecting`?
'
)
throw
new
Error
(
'
do not call quit again when quiting
'
)
}
this
.
readyStat
us
(
'
disconnecting
'
)
this
.
readyStat
e
(
'
disconnecting
'
)
// this.clearWatchDogTimer()
this
.
emit
(
'
watchdog
'
,
{
...
...
@@ -136,7 +136,7 @@ class PuppetWeb extends Puppet {
})
.
then
(()
=>
{
// Finally, Fail Safe
log
.
verbose
(
'
PuppetWeb
'
,
'
quit() done
'
)
this
.
readyStat
us
(
'
disconnected
'
)
this
.
readyStat
e
(
'
disconnected
'
)
return
this
// for Chaining
})
}
...
...
src/puppet-web/watchdog.js
浏览文件 @
a5e9c930
...
...
@@ -56,7 +56,7 @@ function onFeed({
throw
new
Error
(
'
Watchdog onFeed: unsupport type
'
+
type
)
}
setWatchDogTimer
.
call
(
this
,
timeout
)
setWatchDogTimer
.
call
(
this
,
timeout
,
(
type
+
'
:
'
+
data
)
)
this
.
emit
(
'
heartbeat
'
,
type
+
'
:
'
+
data
)
...
...
@@ -78,7 +78,7 @@ function clearWatchDogTimer() {
}
}
function
setWatchDogTimer
(
timeout
)
{
function
setWatchDogTimer
(
timeout
,
feed
)
{
clearWatchDogTimer
.
call
(
this
)
...
...
@@ -89,9 +89,13 @@ function setWatchDogTimer(timeout) {
// block quit, force to use quit() // this.watchDogTimer.unref() // dont block quit
}
function
watchDogReset
(
timeout
)
{
function
watchDogReset
(
timeout
,
lastFeed
)
{
log
.
verbose
(
'
PuppetWebWatchdog
'
,
'
watchDogReset() timeout %d
'
,
timeout
)
const
e
=
new
Error
(
'
watchdog reset after
'
+
Math
.
floor
(
timeout
/
1000
)
+
'
seconds
'
)
const
e
=
new
Error
(
'
watchdog reset after
'
+
Math
.
floor
(
timeout
/
1000
)
+
'
seconds, last feed:
'
+
'
[
'
+
lastFeed
+
'
]
'
)
this
.
emit
(
'
error
'
,
e
)
return
Event
.
onBrowserDead
.
call
(
this
,
e
)
}
...
...
src/puppet.js
浏览文件 @
a5e9c930
...
...
@@ -21,15 +21,15 @@ class Puppet extends EventEmitter {
* connected / disconnected
* connecting / disconnecting
*/
this
.
_readyStat
us
=
'
disconnected
'
this
.
_readyStat
e
=
'
disconnected
'
}
readyStat
us
(
newStatus
)
{
if
(
newStat
us
)
{
log
.
verbose
(
'
Puppet
'
,
'
readyStat
us(%s)
'
,
newStatus
)
this
.
_readyStat
us
=
newStatus
readyStat
e
(
newState
)
{
if
(
newStat
e
)
{
log
.
verbose
(
'
Puppet
'
,
'
readyStat
e(%s)
'
,
newState
)
this
.
_readyStat
e
=
newState
}
return
this
.
_readyStat
us
return
this
.
_readyStat
e
}
/**
...
...
test/puppet.spec.js
0 → 100644
浏览文件 @
a5e9c930
const
test
=
require
(
'
tape
'
)
const
Wechaty
=
require
(
'
../
'
)
const
Puppet
=
Wechaty
.
Puppet
test
(
'
Puppet smoking test
'
,
t
=>
{
const
p
=
new
Puppet
()
t
.
equal
(
p
.
readyState
(),
'
disconnected
'
,
'
should be disconnected state after instanciate
'
)
p
.
readyState
(
'
connecting
'
)
t
.
equal
(
p
.
readyState
(),
'
connecting
'
,
'
should be connecting state after set
'
)
t
.
end
()
})
test/wechaty.spec.js
浏览文件 @
a5e9c930
const
test
=
require
(
'
tape
'
)
const
Wechaty
=
require
(
'
../
'
)
test
(
'
Wechaty Framework
'
,
function
(
t
)
{
const
Wechaty
=
require
(
'
../
'
)
test
(
'
Wechaty Framework
'
,
t
=>
{
t
.
ok
(
Wechaty
,
'
should export Wechaty
'
)
t
.
ok
(
Wechaty
.
Message
,
'
should export Wechaty.Message
'
)
t
.
ok
(
Wechaty
.
Contact
,
'
should export Wechaty.Contact
'
)
...
...
@@ -21,8 +21,7 @@ test('Wechaty Framework', function(t) {
t
.
end
()
})
test
(
'
Wechaty config setting
'
,
function
(
t
)
{
const
Wechaty
=
require
(
'
../
'
)
test
(
'
Wechaty config setting
'
,
t
=>
{
const
config
=
Wechaty
.
config
t
.
ok
(
config
,
'
should export Wechaty.config
'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录