Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_46011646
wechaty
提交
037f39c8
W
wechaty
项目概览
weixin_46011646
/
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,发现更多精彩内容 >>
提交
037f39c8
编写于
6月 12, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix scan event lost bug, and prevent browser restart when we only need a refresh
上级
b3aeb8b2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
5 deletion
+31
-5
src/puppet-web-browser.js
src/puppet-web-browser.js
+6
-1
src/puppet-web.js
src/puppet-web.js
+25
-4
未找到文件。
src/puppet-web-browser.js
浏览文件 @
037f39c8
...
...
@@ -89,6 +89,11 @@ class Browser extends EventEmitter {
})
}
refresh
()
{
log
.
verbose
(
'
PuppetWebBrowser
'
,
'
refresh()
'
)
return
this
.
driver
.
navigate
().
refresh
()
}
getPhantomJsDriver
()
{
// https://github.com/SeleniumHQ/selenium/issues/2069
// setup custom phantomJS capability
...
...
@@ -229,7 +234,7 @@ class Browser extends EventEmitter {
return
this
.
driver
.
executeScript
.
apply
(
this
.
driver
,
arguments
)
.
catch
(
e
=>
{
this
.
dead
(
e
.
message
)
this
.
dead
(
e
)
throw
e
})
}
...
...
src/puppet-web.js
浏览文件 @
037f39c8
...
...
@@ -127,7 +127,7 @@ class PuppetWeb extends Puppet {
if
(
this
.
session
)
{
yield
this
.
browser
.
loadSession
(
this
.
session
)
.
catch
(
e
=>
{
// fail safe
log
.
verbose
(
'
PuppetWeb
'
,
'
browser.loadSession(
) exception: %s
'
,
e
.
message
||
e
)
log
.
verbose
(
'
PuppetWeb
'
,
'
browser.loadSession(
%s) exception: %s
'
,
this
.
session
,
e
.
message
||
e
)
})
}
yield
this
.
browser
.
open
()
...
...
@@ -243,7 +243,7 @@ class PuppetWeb extends Puppet {
},
TIMEOUT
)
this
.
watchDogTimer
.
unref
()
// dont block quit
const
SAVE_SESSION_INTERVAL
=
5
*
60
*
1000
// 5 min
const
SAVE_SESSION_INTERVAL
=
5
*
60
*
1000
// 5 min
s
if
(
this
.
session
)
{
if
(
!
this
.
watchDogLastSaveSession
||
Date
.
now
()
-
this
.
watchDogLastSaveSession
>
SAVE_SESSION_INTERVAL
)
{
log
.
verbose
(
'
PuppetWeb
'
,
'
watchDog() saveSession(%s) after %d minutes
'
,
this
.
session
,
Math
.
floor
(
SAVE_SESSION_INTERVAL
/
1000
/
60
))
...
...
@@ -251,6 +251,23 @@ class PuppetWeb extends Puppet {
this
.
watchDogLastSaveSession
=
Date
.
now
()
}
}
// if web browser stay at login qrcode page long time,
// sometimes the qrcode will not refresh, leave there expired.
// so we need to refresh the page after a while
const
REFRESH_TIMEOUT
=
10
*
60
*
1000
// 10 mins
if
(
!
this
.
logined
())
{
if
(
!
this
.
watchDogLastRefresh
)
{
this
.
watchDogLastRefresh
=
Date
.
now
()
}
if
(
Date
.
now
()
-
this
.
watchDogLastRefresh
>
REFRESH_TIMEOUT
)
{
log
.
warn
(
'
PuppetWeb
'
,
'
watchDog() refresh browser for not login for a long time
'
)
this
.
browser
.
refresh
()
this
.
watchDogLastRefresh
=
Date
.
now
()
}
}
else
if
(
this
.
watchDogLastRefresh
)
{
this
.
watchDogLastRefresh
=
null
}
}
onServerDing
(
data
)
{
...
...
@@ -287,11 +304,15 @@ class PuppetWeb extends Puppet {
return
}
else
{
// browser is alive, and we have a bridge to it
log
.
verbose
(
'
PuppetWeb
'
,
'
onServerDisconnect() re-initing bridge
'
)
process
.
nextTick
(()
=>
{
// must use setTimeout to wait a while.
// because the browser has just refreshed, need some time to re-init to ready.
// if the browser is not ready, bridge init will fail,
// caused browser dead and have to be restarted. 2016/6/12
setTimeout
(()
=>
{
this
.
bridge
.
init
()
.
then
(
r
=>
log
.
verbose
(
'
PuppetWeb
'
,
'
onServerDisconnect() bridge re-inited: %s
'
,
r
))
.
catch
(
e
=>
log
.
error
(
'
PuppetWeb
'
,
'
onServerDisconnect() exception: [%s]
'
,
e
))
})
}
,
1000
)
return
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录