﻿//global data
var roomList = null;
var choosedRoomType;
var createRoomResult = null;

//business methods
function GetRoomList(roomType) {
    choosedRoomType = roomType;
    $.ajax({
        type: "POST",
        //url: "http://localhost:1771/WebServices/BoardService.asmx/GetRoomList",
        url: "http://tankforce.com/WebServices/BoardService.asmx/GetRoomList",
        data: "{'roomType':"+roomType+"}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {
            roomList = jQuery.parseJSON(msg.d);
        },
        error: function(msg) {
            alert('GetRoomList failed!');
        }
    });
}

function CreateRoom(roomType, ownerId, roomName, roomPassword, playerKey) {
    $.ajax({
        type: "POST",
        url: "http://tankforce.com/WebServices/BoardService.asmx/CreateRoom",
        data: "{'roomType':" + roomType + ", 'ownerId':" + ownerId + ",'name':'" + roomName + "','password':'" + roomPassword + "','key':'" + playerKey + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {
            createRoomResult = jQuery.parseJSON(msg.d);
        },
        error: function(msg) {
            alert('CreateRoom failed!');
        }
    });
}

//end business methods

