function Network() {
    function sendGameRequest(numPlayers) {
        var message = {"NumPlayers": numPlayers}
        sendMessage(NEW_GAME_CMD, message)
    }

    function sendClientInfo(playerId) {
        var message = {"Id": playerId}
        sendMessage(CLIENT_INFO_CMD, message);
    }

    CLIENT_INFO_CMD = "clientInfo";
    NEW_GAME_CMD = "newGame";

    host = window.location.host.split(":")[0];
    port = "8888"
    ws_addr = "ws://" + host + ":" + port + "/ws"
    conn = new WebSocket(ws_addr);
    DELIM = ":"

    // This function expects the message as a javascript object
    function sendMessage(command, messageObj) {
        var jsonified = JSON.stringify(messageObj)
        packet = command + DELIM + jsonified;
        conn.send(packet)
    }

    // When the connection is open, send some data to the server
    conn.onopen = function () {
        network.sendClientInfo(getPlayerId());
    };

    // Log errors
    conn.onerror = function (error) {
        console.log('WebSocket Error ' + error);
    };

    // Log messages from the server
    conn.onmessage = function (e) {
        console.log('Server: ' + e.data);
    };

    this.sendGameRequest = function(numPlayers) {
        sendGameRequest(numPlayers);
    }

    this.sendClientInfo = function(playerId) {
        sendClientInfo(playerId);
    }
}

@@ -10,24 +10,65 @@
 Network() %7B%0A
+    // To server functions and constants%0A
     function
@@ -326,24 +326,103 @@
 ge);%0A    %7D%0A%0A
+    function sendViewWorld() %7B%0A        sendMessage(VIEW_WORLD_CMD, %7B%7D);%0A    %7D%0A%0A
     CLIENT_I
@@ -474,16 +474,45 @@
 ewGame%22;
+%0A    VIEW_WORLD_CMD = %22view%22;
 %0A%0A    ho
@@ -910,24 +910,214 @@
 ket)%0A    %7D%0A%0A
+    // From server functions and constants%0A    this.packetHandlers = %7B%0A        %22view%22: parseViewWorld,%0A    %7D%0A%0A    function parseViewWorld(status, world) %7B%0A        console.log(world);%0A    %7D%0A%0A
     // When 
@@ -1453,229 +1453,1017 @@
     
-console.log('Server: ' + e.data);%0A    %7D;%0A%0A    this.sendGameRequest = function(numPlayers) %7B%0A        sendGameRequest(numPlayers);%0A    %7D%0A%0A    this.sendClientInfo = function(playerId) %7B%0A        sendClientInfo(playerId);%0A    %7D
+var cmds = e.data.actualSplit(DELIM, 3);%0A        console.log(cmds);%0A        var pkt_type = cmds%5B0%5D;%0A        var status = cmds%5B1%5D;%0A        if (cmds.length %3E 2) %7B%0A            console.log(cmds%5B2%5D);%0A            var dataObj = JSON.parse(cmds%5B2%5D);%0A            console.log(pkt_type, status, dataObj);%0A            var handler = this.packetHandlers%5Bpkt_type%5D;%0A            if (handler != null) %7B%0A                handler(status, dataObj);%0A            %7D else %7B%0A                console.log(%22Recieved unknown command:%22, pkt_type);%0A            %7D%0A        %7D%0A    %7D;%0A%0A    this.sendGameRequest = function(numPlayers) %7B%0A        sendGameRequest(numPlayers);%0A    %7D%0A%0A    this.sendClientInfo = function(playerId) %7B%0A        sendClientInfo(playerId);%0A    %7D%0A%0A    this.sendViewWorld = function() %7B%0A        sendViewWorld();%0A    %7D%0A%7D%0A%0AString.prototype.actualSplit = function(sep, maxsplit) %7B%0A    var split = this.split(sep);%0A    return maxsplit ? split.slice(0, maxsplit - 1).concat(split.slice(maxsplit - 1, split.length).join(%22:%22)) : split;
 %0A%7D%0A

Send world view request and parse the response