/Donovyn_Naman_MultiUserDungeon

Totally not a glorified chat server!

Primary LanguageGroff

Racket Chat

##Authors:

####Donovyn Pickler

####Naman Jiandani

##Overview:

This project is a client-server chat application. Once connected, clients are able to communicate with other users on the server. The server acts as a relay that all messages pass through.

There should be a diagram here

##Screenshot: There should be a screenshot here here

##Concepts Demonstrated:

Identify the OPL concepts demonstrated in your project. Be brief. A simple list and example is sufficient.

Data abstraction is used to in the storage of connection info. Recursion is used to ensure that no messages are missed by the server, and that all messages get sent to all users.

##Favorite Scheme Expressions:

####Donovyn:

(define (get-connection port) ;;Gets the ports from a connection and shoves them into a list
  (let-values ([(i o) (tcp-accept (tcp-listen port))])
    (when (not (eqv? i null))
      (add-connection i o)
      ;(write "You have connected, waiting for another user" o) ;confirmation message
      ;(flush-output o)
      )
    )
  )

paird with

(define (add-connection in out) ;;Adds a pair of in and out ports to a list of pairs of in and out ports
(set! conn_list (cons (list in out) conn_list))
)

With a little more understanding on how to dynamically recognize when someone is trying to connect, these two could easily allow for connecting to and cataloging an arbitrary number of users

####Naman:

These lines are decriptive of how the racket/gui library provides support for event handling and management: the callback functionality is used to correctly handle events like button clicks, entries in a field, etc. I found this to be a less cluttered and elegant format, compared to how other languages suppoer event handling in their GUI components.

(define (make-buttons) ;makes the buttons for send, fetch, and clear.
  
  (new button% [parent panel1] [label "Send!"]
       [callback (lambda (button event)
                   (set! user1message (send textfield-1 get-value))
                   (send textfield-1 set-value "")
                   (set! msg-item (list user1 user1message))
                   (send-message msg-item);added
                   
                   )
                 ]
       )
  
  (new button% [parent panel1] [label "Fetch Message"] [style (list 'border)]
       [callback (lambda (button event)
                   ;(for (#:when (char-ready? in))
                   (when (char-ready? in) (set! in-msg (read in)))
                   (when (not (eqv? in-msg "")) (send received-text set-value (print-message in-msg)))
                   (set! in-msg "")
                   ;  )
                   )
                 ]
       )
  
  (new button% [parent panel1] [label "Clear"]
       [callback (lambda (button event)
                   (set! gbl-text "")
                   (send received-text set-value gbl-text)
                   )
                 ]
       )
  
  )

##Additional Remarks:

##How to Download and Run:

A downloadable version of the project is available in tar.gz format, just click HERE.

###How to run: (Due to crappy school internet, all future tests of this must be done on the same machine)

  1. extract the contents of the tar.gz archive completely

  2. Open each of the racket files with DrRacket or your compiler of choice.

  3. First start by running the server software.

3a) A window should pop up with a large button that says "Run the server!", click that button.

  1. Now run the software labeled "User 1.rkt".

    4a) Enter your desired username in the slim text field at the top of the window, then click "Register Users"

  2. Now run the software labeled "user 2.rkt".

    5a) Enter your desired username in the slim text field at the top of the window, then click "Register Users"

    The following may be done on either or both User chat windows.

  3. Additional text may be entered in the text field at the top of the window.

6a) That text may be sent to all connected users by clicking the "Send!" button.

  1. To recieve messages from the server, click the "Fetch Message" button.

    7a) each time you press the "Fetch Message" button, you will recieve one message from the server. (Had issues making it recursive)

  2. Pressing the "Clear" button will clear the chat field, leaving it open for additional dialogue.