Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
shrapnel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
shrapnel
Commits
82c3f321
Commit
82c3f321
authored
Jun 21, 2012
by
Sam Rushing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simple websocket echo server
parent
61853b48
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
coro/http/demo/websocket/echo_server.py
coro/http/demo/websocket/echo_server.py
+36
-0
No files found.
coro/http/demo/websocket/echo_server.py
0 → 100644
View file @
82c3f321
# -*- Mode: Python -*-
from
coro.http.websocket
import
handler
,
websocket
import
coro
W
=
coro
.
write_stderr
class
echo_server
(
websocket
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
pending
=
[]
websocket
.
__init__
(
self
,
*
args
,
**
kwargs
)
def
handle_packet
(
self
,
p
):
#W ('packet=%r\n' % (p,))
self
.
pending
.
append
(
p
.
unpack
())
if
p
.
fin
:
data
,
self
.
pending
=
self
.
pending
,
[]
self
.
send_text
(
''
.
join
(
data
))
return
False
if
__name__
==
'__main__'
:
import
coro.http
import
coro.backdoor
fh
=
coro
.
http
.
handlers
.
favicon_handler
()
sh
=
coro
.
http
.
handlers
.
coro_status_handler
()
wh
=
handler
(
'/echo'
,
echo_server
)
handlers
=
[
fh
,
sh
,
wh
]
#server = coro.http.server (('0.0.0.0', 9001))
server
=
coro
.
http
.
server
()
for
h
in
handlers
:
server
.
push_handler
(
h
)
#coro.spawn (server.start)
coro
.
spawn
(
server
.
start
,
(
'0.0.0.0'
,
9001
))
coro
.
spawn
(
coro
.
backdoor
.
serve
,
unix_path
=
'/tmp/ws.bd'
)
coro
.
event_loop
(
30.0
)
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