Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
haoqu.ma
/
gotty
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 00ddf781
authored
Aug 31, 2015
by
Iwasaki Yudai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send ping/pong
1 parent
b711de49
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
18 deletions
app/client_context.go
app/resource.go
resources/gotty.js
app/client_context.go
View file @
00ddf78
...
...
@@ -24,14 +24,16 @@ type clientContext struct {
const
(
Input
=
'0'
ResizeTerminal
=
'1'
Ping
=
'1'
ResizeTerminal
=
'2'
)
const
(
Output
=
'0'
SetWindowTitle
=
'1'
SetPreferences
=
'2'
SetReconnect
=
'3'
Pong
=
'1'
SetWindowTitle
=
'2'
SetPreferences
=
'3'
SetReconnect
=
'4'
)
type
argResizeTerminal
struct
{
...
...
@@ -161,6 +163,8 @@ func (context *clientContext) processReceive() {
return
}
case
Ping
:
context
.
connection
.
WriteMessage
(
websocket
.
TextMessage
,
[]
byte
{
Pong
})
case
ResizeTerminal
:
var
args
argResizeTerminal
err
=
json
.
Unmarshal
(
data
[
1
:
],
&
args
)
...
...
app/resource.go
View file @
00ddf78
This diff could not be displayed because it is too large.
resources/gotty.js
View file @
00ddf78
...
...
@@ -9,9 +9,13 @@
var
term
;
var
pingTimer
;
ws
.
onopen
=
function
(
event
)
{
ws
.
send
(
gotty_auth_token
);
pingTimer
=
setInterval
(
sendPing
,
30
*
1000
,
ws
);
hterm
.
defaultStorage
=
new
lib
.
Storage
.
Local
();
hterm
.
defaultStorage
.
clear
();
...
...
@@ -30,7 +34,7 @@
io
.
onTerminalResize
=
function
(
columns
,
rows
)
{
ws
.
send
(
"
1
"
+
JSON
.
stringify
(
"
2
"
+
JSON
.
stringify
(
{
columns
:
columns
,
rows
:
rows
,
...
...
@@ -52,39 +56,40 @@
term
.
io
.
writeUTF16
(
data
);
break
;
case
'1'
:
// pong
case
'2'
:
term
.
setWindowTitle
(
data
);
break
;
case
'
2
'
:
case
'
3
'
:
preferences
=
JSON
.
parse
(
data
);
Object
.
keys
(
preferences
).
forEach
(
function
(
key
)
{
console
.
log
(
"Setting "
+
key
+
": "
+
preferences
[
key
]);
term
.
getPrefs
().
set
(
key
,
preferences
[
key
]);
});
break
;
case
'
3
'
:
case
'
4
'
:
autoReconnect
=
JSON
.
parse
(
data
);
console
.
log
(
"Enabling reconnect: "
+
autoReconnect
+
" seconds"
)
break
;
}
}
}
;
ws
.
onclose
=
function
(
event
)
{
if
(
term
)
{
term
.
uninstallKeyboard
();
term
.
io
.
showOverlay
(
"Connection Closed"
,
null
);
}
tryReconnect
();
}
ws
.
onerror
=
function
(
error
)
{
tryReconnect
();
clearInterval
(
pingTimer
);
if
(
autoReconnect
>
0
)
{
setTimeout
(
openWs
,
autoReconnect
*
1000
);
}
};
}
openWs
();
var
tryReconnect
=
function
()
{
if
(
autoReconnect
>=
0
)
{
setTimeout
(
openWs
,
autoReconnect
*
1000
);
}
var
sendPing
=
function
(
ws
)
{
ws
.
send
(
"1"
);
}
openWs
();
})()
Write
Preview
Markdown
is supported
Attach a file
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 post a comment