Last change
on this file since 88 was 88, checked in by Bart Vastenhouw, 3 years ago |
Added python SimpleRunner GUI
|
File size:
1018 bytes
|
Rev | Line | |
---|
[88] | 1 | from abc import ABC, abstractmethod
|
---|
| 2 |
|
---|
| 3 | from geniusweb.profileconnection.Session import Session
|
---|
| 4 |
|
---|
| 5 |
|
---|
| 6 | class WebSocketClient(ABC):
|
---|
| 7 | '''
|
---|
| 8 | Interface for client listening to websocket events.
|
---|
| 9 | This basically hides the python websocket app,
|
---|
| 10 | so that we can ensure the functions are implemented
|
---|
| 11 | and allows us to pass mock clients.
|
---|
| 12 | '''
|
---|
| 13 | @abstractmethod
|
---|
| 14 | def onOpen(self, session:Session):
|
---|
| 15 | '''
|
---|
| 16 | called when the socket opens. Clients should store the session
|
---|
| 17 | '''
|
---|
| 18 | @abstractmethod
|
---|
| 19 | def onClose(self):
|
---|
| 20 | '''
|
---|
| 21 | called when session closes.
|
---|
| 22 | '''
|
---|
| 23 |
|
---|
| 24 | @abstractmethod
|
---|
| 25 | def onMessage(self, text:str):
|
---|
| 26 | '''
|
---|
| 27 | called when message comes for the client
|
---|
| 28 | '''
|
---|
| 29 | @abstractmethod
|
---|
| 30 | def onError(self, error:BaseException):
|
---|
| 31 | '''
|
---|
| 32 | @param error the error that occured
|
---|
| 33 | '''
|
---|
| 34 |
|
---|
| 35 | @abstractmethod
|
---|
| 36 | def close(self):
|
---|
| 37 | '''
|
---|
| 38 | When this is called, the client should close and free its resources.
|
---|
| 39 | ''' |
---|
Note:
See
TracBrowser
for help on using the repository browser.