+;;; Mudsync --- Live hackable MUD
+;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
+;;;
+;;; This file is part of Mudsync.
+;;;
+;;; Mudsync is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or
+;;; (at your option) any later version.
+;;;
+;;; Mudsync is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with Mudsync. If not, see <http://www.gnu.org/licenses/>.
+
(define-module (mudsync networking)
#:use-module (8sync systems actors)
#:use-module (8sync agenda)
(define %default-port 8889)
(define-class <network-manager> (<actor>)
- (server-socket #:accessor nm-server-socket)
+ (server-socket #:getter nm-server-socket)
;; mapping of client -> client-id
- (clients #:accessor nm-clients
+ (clients #:getter nm-clients
#:init-thunk make-hash-table)
;; send input to this actor
(send-input-to #:getter nm-send-input-to
;; (sigaction SIGPIPE SIG_IGN)
;; Will this break other things that use pipes for us though?
- (set! (nm-server-socket nm) s)
+ (slot-set! nm 'server-socket s)
(format #t "Listening for clients in pid: ~s\n" (getpid))
(8sync-port s #:read (lambda (s) (nm-new-client nm s)))
"Handle a closed port"
(format #t "DEBUG: handled closed port ~x\n" client-id)
(8sync-port-remove client)
- (hash-remove! (nm-clients nm) client-id))
+ (hash-remove! (nm-clients nm) client-id)
+ (<- nm (nm-send-input-to nm) 'client-closed #:client 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)
(8sync-port-remove client)
- (hash-remove! (nm-clients nm) client-id))
+ (hash-remove! (nm-clients nm) client-id)
+ (<- nm (nm-send-input-to nm) 'client-closed #:client client-id))
(define-method (nm-handle-line nm client client-id line)
"Handle an incoming line of input from a client"