Browse code
Add a restart and a connection-lost condition
Showing 1 changed files
... | ... |
@@ -43,6 +43,9 @@ |
43 | 43 |
(defgeneric start-module (client module) |
44 | 44 |
(:documentation "start a module")) |
45 | 45 |
|
46 |
+(define-condition connection-lost () |
|
47 |
+ ()) |
|
48 |
+ |
|
46 | 49 |
(defun start-client (&key modules) |
47 | 50 |
(let* ((event-pump (make-instance 'event-pump)) |
48 | 51 |
(client (make-client event-pump))) |
... | ... |
@@ -59,7 +62,12 @@ |
59 | 62 |
(websocket-driver:start-connection client) |
60 | 63 |
|
61 | 64 |
(as:with-interval (15) |
62 |
- (send-message event-pump :ping)) |
|
65 |
+ (restart-case |
|
66 |
+ (if (> 100 (waiting-pings event-pump)) |
|
67 |
+ (send-message event-pump :ping) |
|
68 |
+ (error 'connection-lost)) |
|
69 |
+ (restart-server () |
|
70 |
+ (websocket-driver:start-connection client)))) |
|
63 | 71 |
|
64 | 72 |
(as:with-interval (0.01) |
65 | 73 |
(multiple-value-bind (message message-p) |