;;; along with Mudsync. If not, see <http://www.gnu.org/licenses/>.
(define-module (mudsync networking)
;;; along with Mudsync. If not, see <http://www.gnu.org/licenses/>.
(define-module (mudsync networking)
#:use-module (8sync agenda)
#:use-module (ice-9 format)
#:use-module (ice-9 match)
#:use-module (8sync agenda)
#:use-module (ice-9 format)
#:use-module (ice-9 match)
(sockaddr:addr client-details)))
(fcntl client F_SETFL (logior O_NONBLOCK (fcntl client F_GETFL)))
(hash-set! (nm-clients nm) client-id client)
(sockaddr:addr client-details)))
(fcntl client F_SETFL (logior O_NONBLOCK (fcntl client F_GETFL)))
(hash-set! (nm-clients nm) client-id client)
(loop))
(define (nm-handle-port-closed nm client client-id)
"Handle a closed port"
(format #t "DEBUG: handled closed port ~x\n" client-id)
(hash-remove! (nm-clients nm) client-id)
(loop))
(define (nm-handle-port-closed nm client client-id)
"Handle a closed port"
(format #t "DEBUG: handled closed port ~x\n" client-id)
(hash-remove! (nm-clients nm) client-id)
(define-method (nm-handle-port-eof nm client client-id)
"Handle seeing an EOF on port"
(format #t "DEBUG: handled eof-object on port ~x\n" client-id)
(close client)
(hash-remove! (nm-clients nm) client-id)
(define-method (nm-handle-port-eof nm client client-id)
"Handle seeing an EOF on port"
(format #t "DEBUG: handled eof-object on port ~x\n" client-id)
(close client)
(hash-remove! (nm-clients nm) client-id)
(define-method (nm-handle-line nm client client-id line)
"Handle an incoming line of input from a client"
(define-method (nm-handle-line nm client client-id line)
"Handle an incoming line of input from a client"