critical bug fix in registration process; please propagate

This commit is contained in:
Matthias Felleisen 2011-04-25 11:05:18 -04:00
parent 88e0631c71
commit f2a475eb43
3 changed files with 10 additions and 9 deletions

View File

@ -136,7 +136,8 @@
;; InPort OutPort (U #f String) -> Void
;; register with the server
(define (tcp-register in out name)
(tcp-send out `(REGISTER ((name ,(if name name (symbol->string (gensym 'world)))))))
(define msg `(REGISTER ((name ,(if name name (symbol->string (gensym 'world)))))))
(tcp-send out msg)
(define ackn (tcp-receive in))
(unless (equal? ackn '(OKAY))
(raise tcp-eof)))

View File

@ -234,9 +234,9 @@
;; IPort OPort Sexp -> IWorld
(define (create-iworld i o info)
(if (and (pair? info) (string? (car info)))
(make-iworld i o (car info) (cdr info))
(make-iworld i o (symbol->string (gensym 'iworld)) info)))
(if (string? info)
(make-iworld i o info "info field not available")
(make-iworld i o (symbol->string (gensym 'iworld)) "info field not available")))
;; Player S-exp -> Void
(define (iworld-send p sexp)

View File

@ -1,6 +1,6 @@
;; The first three lines of this file were inserted by DrScheme. They record metadata
;; The first three lines of this file were inserted by DrRacket. They record metadata
;; about the language level of this file in a form that our tools can easily process.
#reader(lib "htdp-intermediate-lambda-reader.ss" "lang")((modname server) (read-case-sensitive #f) (teachpacks ()) (htdp-settings #(#f constructor repeating-decimal #f #t none #f ())))
#reader(lib "htdp-intermediate-lambda-reader.ss" "lang")((modname server) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
(require 2htdp/universe)
;; UniState = [Listof IWorld]
@ -91,10 +91,10 @@
;; Any -> Universe
;; run the chat server
(define (run _)
(define (run debug)
(universe '()
(state true)
(state debug)
(on-new new-chatter)
(on-msg forward)))
(run 0)
(run #true)