2 (in-package :lambdamundo
)
4 ;; (unless (find-package :swank)
5 ;; (swank-loader:init))
8 (defparameter *swank-port
* nil
)
9 (defparameter *service-slime
* t
)
13 (defun start-session (port)
14 "starts a swank session and returns "
15 (let* ((announce-fn #'simple-announce-function
)
16 (external-format (find-external-format-or-lose *coding-system
*))
17 (socket (create-socket *loopback-interface
* port
))
18 (local-port (local-port socket
)))
19 (declare (type function announce-fn
))
20 (funcall announce-fn local-port
)
21 (format *debug-io
* "Swank on port ~A " local-port
)
22 (initialize-multiprocessing
27 (serve-connection socket
:spawn t external-format
))
28 while lambdamundo
::*service-slime
*))
30 (concatenate 'string
"Swank "
31 (princ-to-string port
)))))
32 (setf (getf *listener-sockets
* port
) (list :sigio socket
))
35 (defun end-session (port)
36 "Stop server running on PORT. Equivalent to swank::stop-server"
37 (let* ((socket-description (getf *listener-sockets
* port
))
38 (socket (second socket-description
)))
39 (let ((thread-position
42 (string-equal (second x
)
43 (concatenate 'string
"Swank "
44 (princ-to-string port
))))
47 (kill-nth-thread thread-position
)
49 (remf *listener-sockets
* port
)))))