Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
J
jensen
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Skye Yu
jensen
Commits
0b8fa873
Commit
0b8fa873
authored
Aug 20, 2025
by
martin hou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 取消对current的使用和控制
parent
f7dc839d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
13 deletions
+36
-13
jensen.js
src/utils/jensen.js
+36
-13
No files found.
src/utils/jensen.js
View file @
0b8fa873
...
@@ -273,7 +273,7 @@ function Jensen(log, conn) {
...
@@ -273,7 +273,7 @@ function Jensen(log, conn) {
const
sendNext
=
async
function
()
{
const
sendNext
=
async
function
()
{
if
(
current
)
{
if
(
current
)
{
// Logger.info('jensen', 'sendNext', 'return cuz current is: ' + current);
// Logger.info('jensen', 'sendNext', 'return cuz current is: ' + current);
return
;
//
return;
}
}
let
cmd
=
null
;
let
cmd
=
null
;
...
@@ -289,7 +289,7 @@ function Jensen(log, conn) {
...
@@ -289,7 +289,7 @@ function Jensen(log, conn) {
}
}
let
data
=
cmd
.
make
();
let
data
=
cmd
.
make
();
current
=
'cmd-'
+
cmd
.
command
+
'-'
+
cmd
.
index
;
//
current = 'cmd-' + cmd.command + '-' + cmd.index;
Logger
.
debug
(
'jensen'
,
'sendNext'
,
pid
+
'-command: '
+
cmd
.
command
+
', data bytes: '
+
data
.
byteLength
);
Logger
.
debug
(
'jensen'
,
'sendNext'
,
pid
+
'-command: '
+
cmd
.
command
+
', data bytes: '
+
data
.
byteLength
);
self
.
timewait
=
cmd
.
command
==
TRANSFER_FILE
||
cmd
.
command
==
GET_FILE_BLOCK
?
1000
:
10
;
self
.
timewait
=
cmd
.
command
==
TRANSFER_FILE
||
cmd
.
command
==
GET_FILE_BLOCK
?
1000
:
10
;
...
@@ -348,22 +348,43 @@ function Jensen(log, conn) {
...
@@ -348,22 +348,43 @@ function Jensen(log, conn) {
trigger
(
resp
,
msgid
);
trigger
(
resp
,
msgid
);
}
}
const
trigger
=
function
(
resp
,
msgid
)
{
const
trigger
=
function
(
resp
,
msgid
,
idx
)
{
/*
if (current == null) return;
if (current == null) return;
Logger.debug('jensen', 'trigger', pid + ':trigger - ' + current.substring(0, current.lastIndexOf('-')) + ' <---> cmd-' + (msgid || 'err'));
Logger.debug('jensen', 'trigger', pid + ':trigger - ' + current.substring(0, current.lastIndexOf('-')) + ' <---> cmd-' + (msgid || 'err'));
if (current.substring(0, current.lastIndexOf('-')) != 'cmd-' + msgid) {
if (current.substring(0, current.lastIndexOf('-')) != 'cmd-' + msgid) {
// current = null;
// current = null;
return;
return;
}
}
if
(
current
in
actions
==
false
)
{
*/
Logger
.
debug
(
'jensen'
,
'trigger'
,
pid
+
':no action registered'
);
return
;
if
(
idx
)
{
let
tag
=
'cmd-'
+
msgid
+
'-'
+
idx
;
if
(
tag
in
actions
==
false
)
{
Logger
.
debug
(
'jensen'
,
'trigger'
,
pid
+
':no action registered'
);
return
;
}
let
p
=
actions
[
tag
];
if
(
p
.
timeout
)
clearTimeout
(
p
.
timeout
);
p
.
resolve
(
resp
);
delete
actions
[
tag
];
}
else
{
// 触发所有的
let
prefix
=
'cmd-'
+
msgid
+
'-'
;
for
(
let
x
in
actions
)
{
let
p
=
actions
[
x
];
if
(
p
.
tag
.
startsWith
(
prefix
))
{
p
.
resolve
(
null
);
delete
actions
[
p
];
}
}
}
}
let
p
=
actions
[
current
];
if
(
p
.
timeout
)
clearTimeout
(
p
.
timeout
);
p
.
resolve
(
resp
);
delete
actions
[
current
];
current
=
null
;
};
};
const
timeout
=
function
(
tag
)
{
const
timeout
=
function
(
tag
)
{
...
@@ -423,7 +444,7 @@ function Jensen(log, conn) {
...
@@ -423,7 +444,7 @@ function Jensen(log, conn) {
};
};
const
tryDecode
=
function
()
{
const
tryDecode
=
function
()
{
if
(
!
current
)
return
;
//
if (!current) return;
// 一个容器,比单独任意一个小包要大一点儿,好像还差一点儿
// 一个容器,比单独任意一个小包要大一点儿,好像还差一点儿
let
stime
=
new
Date
();
let
stime
=
new
Date
();
let
buff
=
new
ArrayBuffer
(
RECV_BUFF_SIZE
*
2
);
let
buff
=
new
ArrayBuffer
(
RECV_BUFF_SIZE
*
2
);
...
@@ -472,7 +493,7 @@ function Jensen(log, conn) {
...
@@ -472,7 +493,7 @@ function Jensen(log, conn) {
let
handler
=
handlers
[
msg
.
id
];
let
handler
=
handlers
[
msg
.
id
];
if
(
!
handler
)
handler
=
Jensen
.
handlers
[
msg
.
id
];
if
(
!
handler
)
handler
=
Jensen
.
handlers
[
msg
.
id
];
let
r
=
handler
(
msg
,
self
);
let
r
=
handler
(
msg
,
self
);
if
(
r
)
trigger
(
r
,
msg
.
id
);
if
(
r
)
trigger
(
r
,
msg
.
id
,
msg
.
sequence
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
error
(
e
);
console
.
error
(
e
);
trigger
(
e
);
trigger
(
e
);
...
@@ -484,6 +505,7 @@ function Jensen(log, conn) {
...
@@ -484,6 +505,7 @@ function Jensen(log, conn) {
if
(
crash
)
{
if
(
crash
)
{
// cmd-5-42
// cmd-5-42
// 5是msgid
// 5是msgid
/*
let msgid = parseInt(current.replace(/^cmd-(\d+)-(\d+)$/gi, '$1'));
let msgid = parseInt(current.replace(/^cmd-(\d+)-(\d+)$/gi, '$1'));
try {
try {
let handler = handlers[msgid];
let handler = handlers[msgid];
...
@@ -495,6 +517,7 @@ function Jensen(log, conn) {
...
@@ -495,6 +517,7 @@ function Jensen(log, conn) {
Logger.error('jensen', 'decode', 'decode error: ' + String(e));
Logger.error('jensen', 'decode', 'decode error: ' + String(e));
}
}
trigger(null, msgid);
trigger(null, msgid);
*/
blocks
.
length
=
0
;
blocks
.
length
=
0
;
break
;
break
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment