Tuesday 11 April 2017

How to print user input to the console?

I am trying to test if the server is being send the input of a user. How do I print the input to the console? Right now the console.log is printing a message (""About to create new room""), but I need the input as well.

Client-side:

// Creating new room
    $("#createNewRoom").click(function(){
      var roomName = $("#createNewRoom").val();
      if ($('#NamingRoom').val().trim() == "") {
        return;
      } else {
            socket.emit("CreateNewRoom", $NamingRoom.val());
            $("#NamingRoom").val("");
            $("#NewRoomWindow").hide();
      }
    });

Server-side:

// Creating new room

client.on("CreateNewRoom", function(roomName){
    console.log("About to create new room");
    rooms = roomName;
    socket.sockets.emit("update-rooms", rooms);
});



via JonasSH

No comments:

Post a Comment