~phill-ridout/openlp/pathlib3

« back to all changes in this revision

Viewing changes to scripts/websocket_client.py

  • Committer: Philip Ridout
  • Date: 2017-08-23 20:13:58 UTC
  • mfrom: (2758.1.1 openlp)
  • Revision ID: phill.ridout@gmail.com-20170823201358-0s1vf3h0q3ma5cyx
HEAD

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python3
 
2
# -*- coding: utf-8 -*-
 
3
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
 
4
 
 
5
###############################################################################
 
6
# OpenLP - Open Source Lyrics Projection                                      #
 
7
# --------------------------------------------------------------------------- #
 
8
# Copyright (c) 2008-2017 OpenLP Developers                                   #
 
9
# --------------------------------------------------------------------------- #
 
10
# This program is free software; you can redistribute it and/or modify it     #
 
11
# under the terms of the GNU General Public License as published by the Free  #
 
12
# Software Foundation; version 2 of the License.                              #
 
13
#                                                                             #
 
14
# This program is distributed in the hope that it will be useful, but WITHOUT #
 
15
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       #
 
16
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for    #
 
17
# more details.                                                               #
 
18
#                                                                             #
 
19
# You should have received a copy of the GNU General Public License along     #
 
20
# with this program; if not, write to the Free Software Foundation, Inc., 59  #
 
21
# Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
 
22
###############################################################################
 
23
 
 
24
import asyncio
 
25
import websockets
 
26
import random
 
27
 
 
28
async def tester():
 
29
    async with websockets.connect('ws://localhost:4317/poll') as websocket:
 
30
 
 
31
        while True:
 
32
            greeting = await websocket.recv()
 
33
            print("< {}".format(greeting))
 
34
            import time
 
35
            time.sleep(random.random() * 3)
 
36
 
 
37
asyncio.get_event_loop().run_until_complete(tester())