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
39e87717
Commit
39e87717
authored
Aug 20, 2025
by
martin hou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 还原消息处理机制
parent
0b8fa873
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
36 deletions
+13
-36
jensen.js
src/utils/jensen.js
+13
-36
No files found.
src/utils/jensen.js
View file @
39e87717
...
@@ -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,43 +348,22 @@ function Jensen(log, conn) {
...
@@ -348,43 +348,22 @@ function Jensen(log, conn) {
trigger
(
resp
,
msgid
);
trigger
(
resp
,
msgid
);
}
}
const
trigger
=
function
(
resp
,
msgid
,
idx
)
const
trigger
=
function
(
resp
,
msgid
)
{
{
/*
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
)
{
if
(
idx
)
{
let
tag
=
'cmd-'
+
msgid
+
'-'
+
idx
;
if
(
tag
in
actions
==
false
)
{
Logger
.
debug
(
'jensen'
,
'trigger'
,
pid
+
':no action registered'
);
Logger
.
debug
(
'jensen'
,
'trigger'
,
pid
+
':no action registered'
);
return
;
return
;
}
}
let
p
=
actions
[
tag
];
let
p
=
actions
[
current
];
if
(
p
.
timeout
)
clearTimeout
(
p
.
timeout
);
if
(
p
.
timeout
)
clearTimeout
(
p
.
timeout
);
p
.
resolve
(
resp
);
p
.
resolve
(
resp
);
delete
actions
[
tag
];
delete
actions
[
current
];
}
current
=
null
;
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
];
}
}
}
};
};
const
timeout
=
function
(
tag
)
{
const
timeout
=
function
(
tag
)
{
...
@@ -444,7 +423,7 @@ function Jensen(log, conn) {
...
@@ -444,7 +423,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
);
...
@@ -493,7 +472,7 @@ function Jensen(log, conn) {
...
@@ -493,7 +472,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
,
msg
.
sequence
);
if
(
r
)
trigger
(
r
,
msg
.
id
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
error
(
e
);
console
.
error
(
e
);
trigger
(
e
);
trigger
(
e
);
...
@@ -505,7 +484,6 @@ function Jensen(log, conn) {
...
@@ -505,7 +484,6 @@ 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
];
...
@@ -517,7 +495,6 @@ function Jensen(log, conn) {
...
@@ -517,7 +495,6 @@ 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