         _.forEach @connections, (c) ->
             console.log "sending message to #{ c.peer }"
             c.send data
+
+    listenForMessage: (connection) ->
+        connection.on "data", (data) =>
+            if data.type == "message"
+                console.log "new message from #{ connection.peer }"
+
+                messages = @state.messages
+                messages.push data.message
+                @setState messages: messages
 
 Settings = React.createClass
     mixins: [React.addons.LinkedStateMixin]


                    @connections.push connection

                    peerIds = @connectionsToPeerIds @connections

                    console.log "connected peers: #{ peerIds }"


                            c.send type: "newConnection", peerIds: peerIds

            if who != "x"
                console.log "acting as #{ who }, normal peer"

                peer.on "connection", (connection) =>

                    console.log "connection from #{ connection.peer }"

                    connection.on "open", =>

                        console.log "connection from #{ connection.peer } open"

                        @connections.push connection

                        @listenForMessage connection

                connection = peer.connect "x"
                console.log "connecting to x, host"

                connection.on "error", (error) =>
                    alert error

                connection.on "open", =>
                    console.log "connection to #{ connection.peer } open"

                    @connections.push connection

                    @listenForMessage connection

                    connection.on "data", (data) =>
                        if data.type == "newConnection"
