public override void read(PacketData _data)
        {
            PacketType_SC type = (PacketType_SC) _data.getShort();

            Debug.Log("RoomState packet recieved : " + type);

            switch( type )
            {
            case PacketType_SC.Room_PlayerArrive:
            {
                int uid = _data.getInt();

                byte[] userIdInBytes = new byte[16];
                _data.getStr( userIdInBytes, userIdInBytes.Length );
                string userId = new string(Encoding.ASCII.GetChars( userIdInBytes ));

                Debug.Log("Player Arrive = uid : " + uid + " userID : " + userId );

                room.userArrive( uid, userId );
            }
                break;
            case PacketType_SC.Room_PlayerLeave:
            {
                int uid = _data.getInt();

                Debug.Log("Player Leave = uid : " + uid );

                room.userLeave( uid );
            }
                break;
            case PacketType_SC.GameStart:
            {
                data["UserInfo"] = user;
                gameStateMachine.changeState( enum_States.GAME, data);
                Application.LoadLevel("Grave");
            }
                break;
            } // switch
        }
        public override void read(PacketData _data)
        {
            PacketType_SC type = (PacketType_SC) _data.getShort();

            //Debug.Log("received packet tpye is " + type);

            onLogining = false;

            switch( type )
            {
            case PacketType_SC.LoginSuccess:
            {
                int uId = _data.getInt();
                user = new User(uId, this.userId,this.userPw);
                data = new Dictionary<string, object>();
                data.Add("UserInfo",user);
                gameStateMachine.changeState(enum_States.LOBBY,data); // login state -> lobby state//
            }
                break;
            case PacketType_SC.LoginFail:
                break;
            }
        }
        public override void read(PacketData _data)
        {
            PacketType_SC type = (PacketType_SC)_data.getShort();

            if( type == PacketType_SC.LobbyPlayersInfo )
            {
            }
            else if( type == PacketType_SC.LobbyRoomsInfo )
            {
                // 기존에 있던 방정보 다 삭제 //
                for(int i=0; i<rooms.Length; ++i)
                    rooms[i] = null;

                // 총 방의 갯수
                totalNumberOfRoom = _data.getInt();

                // 현재 페이지의 방 갯수 //
                int nRoomsInPage = _data.getInt();

                //Debug.Log("nRooms In Page : " + nRoomsInPage );

                // 매 방마다 초기화 //
                for(int i=0; i<nRoomsInPage; ++i)
                {
                    // 방 ID //
                    int roomId = _data.getInt();

                    // 방 이름 //
                    byte[] nameOfRoom = new byte[16];
                    _data.getStr( nameOfRoom, 16 );
                    string name = new string(Encoding.ASCII.GetChars( nameOfRoom ));
                    Debug.Log(i + "th Room Name : " + name);

                    // 맵 ID //
                    int mapId = _data.getInt();

                    // 방에 있는 유져 //
                    int nUsersInRoom = _data.getInt();

                    // 방이 게임 중인지 아닌지 //
                    bool onPlaying = _data.getBoolean();

                    //int _id, string newRoomName, Map _map //
                    rooms[i] = new Room( roomId, name, Map.getMap( mapId ), nUsersInRoom );

                }

            }
            else if( type == PacketType_SC.CreateRoom_Success )
            {
                int roomId = _data.getInt();

                Room newRoom = new Room( roomId, creatingRoomName, currentCreatingMap, 1 );
                newRoom.setCreator( user );

                ArrayList users = new ArrayList();
                users.Add( user );
                newRoom.setUsers(users);

                data["RoomInfo"] = newRoom ;
                data["UserInfo"] = user ;

                gameStateMachine.changeState( enum_States.ROOM, data );
            }

            else if( type == PacketType_SC.JoinRoom_Success )
            {

                //Debug.Log("Join Success");
                Room joiningRoom = null;
                ArrayList usersInRoom = new ArrayList();

                // find room
                int roomId = _data.getInt();
                for(int i=0; i<6; ++i){
                    if( roomId == rooms[i].getId() ){
                        joiningRoom = rooms[i];
                        break;
                    }
                }

                if( joiningRoom == null )
                    return;

                // init users //
                int nUsers = _data.getInt();
                int ownerId = _data.getInt();
                for(int i=0; i<nUsers; ++i)
                {
                    int uid = _data.getInt();
                    byte[] userIDInBytes = new byte[16+1];
                    _data.getStr( userIDInBytes, 16 );
                    string userID = new string(Encoding.ASCII.GetChars( userIDInBytes ));

                    User newUser = new User( uid, userID, "");
                    usersInRoom.Add( newUser );

                    //set owner
                    if(  uid == ownerId )
                        joiningRoom.setCreator(newUser);
                }
                usersInRoom.Add( user );

                // replace rooms users
                joiningRoom.setUsers( usersInRoom );

                data["RoomInfo"] = joiningRoom ;
                data["UserInfo"] = user ;

                gameStateMachine.changeState(enum_States.ROOM,data);
            }
            else if( type == PacketType_SC.JoinRoom_Full )
            {
                Debug.Log("Join Full");

            }
            else if( type == PacketType_SC.JoinRoom_Fail )
            {
                Debug.Log("Join Fail");
            }
        }