'Retrieve all state events for a given room. If the user is
joined to the room then return the current state. If the user has
left the room return the state events from when they left.
Args:
user_id(str): The user requesting state events.
room_id(str): The room ID to get all state events from.
Returns:
A list of dicts representing state events. [{}, {}, {}]'

@defer.inlineCallbacks
def get_state_events(self, user_id, room_id, is_guest=False):

    (membership, membership_event_id) = (yield self._check_in_room_or_world_readable(room_id, user_id))
    if (membership == Membership.JOIN):
        room_state = (yield self.state_handler.get_current_state(room_id))
    elif (membership == Membership.LEAVE):
        room_state = (yield self.store.get_state_for_events([membership_event_id], None))
        room_state = room_state[membership_event_id]
    now = self.clock.time_msec()
    defer.returnValue([serialize_event(c, now) for c in room_state.values()])
