예제 #1
0
    public override void OnResponse(string data)
    {
        if (data.Equals("EMPTY"))
        {
            //没有数据,说明没有房间-剩余交给RoomListPanel处理
            _roomListPanel.HandleListRoomResponse(0, null);
            return;
        }
        //否则有数据
        List <RoomInfo> roomInfoList = new List <RoomInfo>();

        string[] roomArr   = data.Split('*');       //1级分割
        int      roomCount = roomArr.Length;        //取得房间个数

        foreach (string temp in roomArr)            //解析每个房间的信息-房主名,房主总次数,房主胜利数
        {
            string[] roomInfoArr = temp.Split('#'); //二级分割
            RoomInfo roomInfo    = new RoomInfo(int.Parse(roomInfoArr[0]), roomInfoArr[1], int.Parse(roomInfoArr[2]), int.Parse(roomInfoArr[3]));
            roomInfoList.Add(roomInfo);
        }
        //数据解析完毕-房间信息已存在这个列表当中-剩余交给RoomListPanel处理
        _roomListPanel.HandleListRoomResponse(roomCount, roomInfoList);
    }