Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
L
luna
Project
Project
Details
Activity
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
ops
luna
Commits
5aac324e
Commit
5aac324e
authored
Jul 18, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 添加重连
parent
bef93b03
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
ssh-term.component.ts
src/app/elements/ssh-term/ssh-term.component.ts
+3
-1
socket.ts
src/app/utils/socket.ts
+2
-2
No files found.
src/app/elements/ssh-term/ssh-term.component.ts
View file @
5aac324e
...
...
@@ -74,6 +74,7 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit, OnDestroy
'token'
:
this
.
token
,
'secret'
:
this
.
secret
,
'size'
:
[
this
.
term
.
cols
,
this
.
term
.
rows
]
};
console
.
log
(
'On token event trigger'
);
this
.
ws
.
emit
(
'token'
,
data
);
}
...
...
@@ -91,13 +92,14 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit, OnDestroy
// 服务器主动断开
this
.
ws
.
on
(
'disconnect'
,
()
=>
{
console
.
log
(
'On disconnect event trigger'
);
this
.
close
();
});
this
.
ws
.
on
(
'logout'
,
(
msg
)
=>
{
const
data
=
msg
.
unmarshal
();
if
(
data
.
room
===
this
.
roomID
)
{
console
.
log
(
'On logout: '
,
data
.
room
,
this
.
roomID
);
console
.
log
(
'On logout
event trigger
: '
,
data
.
room
,
this
.
roomID
);
this
.
view
.
connected
=
false
;
}
});
...
...
src/app/utils/socket.ts
View file @
5aac324e
...
...
@@ -27,7 +27,7 @@ export async function getWsSock(url: string, namespace: string): Promise<Socket>
const
events
=
{};
events
[
namespace
]
=
{
_OnNamespaceConnected
:
function
(
ns
,
msg
)
{
emitter
.
emit
(
'connect'
,
ns
);
emitter
.
emit
(
'connect'
,
ns
);
},
_OnNamespaceDisconnect
:
function
(
ns
,
msg
)
{
...
...
@@ -46,7 +46,7 @@ export async function getWsSock(url: string, namespace: string): Promise<Socket>
emitter
.
emit
(
msg
.
Event
,
msg
);
}
};
const
options
=
{
reconn
nect
:
5
};
const
options
=
{
reconn
ect
:
5000
};
const
conn
=
<
neffos
.
Conn
>
await
neffos
.
dial
(
url
,
events
,
options
);
const
nsConn
=
<
neffos
.
NSConn
>
await
conn
.
connect
(
namespace
);
const
sock
=
new
Socket
(
nsConn
,
emitter
);
...
...
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