critical bug fix in registration process; please propagate
This commit is contained in:
parent
88e0631c71
commit
f2a475eb43
|
@ -136,7 +136,8 @@
|
||||||
;; InPort OutPort (U #f String) -> Void
|
;; InPort OutPort (U #f String) -> Void
|
||||||
;; register with the server
|
;; register with the server
|
||||||
(define (tcp-register in out name)
|
(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))
|
(define ackn (tcp-receive in))
|
||||||
(unless (equal? ackn '(OKAY))
|
(unless (equal? ackn '(OKAY))
|
||||||
(raise tcp-eof)))
|
(raise tcp-eof)))
|
||||||
|
|
|
@ -234,9 +234,9 @@
|
||||||
|
|
||||||
;; IPort OPort Sexp -> IWorld
|
;; IPort OPort Sexp -> IWorld
|
||||||
(define (create-iworld i o info)
|
(define (create-iworld i o info)
|
||||||
(if (and (pair? info) (string? (car info)))
|
(if (string? info)
|
||||||
(make-iworld i o (car info) (cdr info))
|
(make-iworld i o info "info field not available")
|
||||||
(make-iworld i o (symbol->string (gensym 'iworld)) info)))
|
(make-iworld i o (symbol->string (gensym 'iworld)) "info field not available")))
|
||||||
|
|
||||||
;; Player S-exp -> Void
|
;; Player S-exp -> Void
|
||||||
(define (iworld-send p sexp)
|
(define (iworld-send p sexp)
|
||||||
|
|
|
@ -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.
|
;; 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)
|
(require 2htdp/universe)
|
||||||
|
|
||||||
;; UniState = [Listof IWorld]
|
;; UniState = [Listof IWorld]
|
||||||
|
@ -91,10 +91,10 @@
|
||||||
|
|
||||||
;; Any -> Universe
|
;; Any -> Universe
|
||||||
;; run the chat server
|
;; run the chat server
|
||||||
(define (run _)
|
(define (run debug)
|
||||||
(universe '()
|
(universe '()
|
||||||
(state true)
|
(state debug)
|
||||||
(on-new new-chatter)
|
(on-new new-chatter)
|
||||||
(on-msg forward)))
|
(on-msg forward)))
|
||||||
|
|
||||||
(run 0)
|
(run #true)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user