Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
192205b1
Commit
192205b1
authored
Jan 23, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added
parent
0377eea9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
websocket.html
examples/websocket.html
+43
-0
No files found.
examples/websocket.html
0 → 100644
View file @
192205b1
<!DOCTYPE html>
<meta
charset=
"utf-8"
/>
<title>
WebSocket Test
</title>
<script
language=
"javascript"
type=
"text/javascript"
>
var
out
=
function
(
message
)
{
var
div
=
document
.
createElement
(
'div'
);
div
.
innerHTML
=
message
;
document
.
getElementById
(
'output'
).
appendChild
(
div
);
};
window
.
onload
=
function
()
{
var
url
=
'ws://'
+
location
.
host
+
'/ws'
;
var
num_messages
=
0
;
websocket
=
new
WebSocket
(
url
);
websocket
.
onopen
=
function
(
ev
)
{
out
(
'CONNECTED'
);
var
msg
=
'Не всё подчиняется разуму. Но всё подчиняется упорству. '
;
out
(
'SENT: '
+
msg
);
websocket
.
send
(
msg
);
};
websocket
.
onclose
=
function
(
ev
)
{
out
(
'DISCONNECTED'
);
};
websocket
.
onmessage
=
function
(
ev
)
{
if
(
!
ev
.
data
)
return
;
// No data, this is a PING message, ignore it
out
(
'<span style="color: blue;">RESPONSE: '
+
ev
.
data
+
' </span>'
);
num_messages
++
;
if
(
num_messages
>
100
)
{
websocket
.
send
(
'exit'
);
}
};
websocket
.
onerror
=
function
(
ev
)
{
out
(
'<span style="color: red; ">ERROR: </span> '
+
ev
.
data
);
};
};
</script>
<style>
div
{
font
:
small
Verdana
;
}
</style>
<h2>
Mongoose WebSocket Test
</h2>
<div
id=
"output"
></div>
</html>
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