//
//  QuickJoinOrCreateRoomRequest.h
//  SFS2X
//
//  Copyright © 2022 GOTOANDPLAY s.n.c | https://www.smartfoxserver.com All rights reserved.
//

#ifndef QuickJoinOrCreateRoomRequest_h
#define QuickJoinOrCreateRoomRequest_h

#endif /* QuickJoinOrCreateRoomRequest */

#import "BaseRequest.h"
#import "MatchExpression.h"
#import "RoomSettings.h"
#import "CreateRoomRequest.h"
#import "Room.h"

EXTERN NSString * const QuickJoinOrCreateRoomRequest_KEY_MATCH_EXPRESSION;
EXTERN NSString * const QuickJoinOrCreateRoomRequest_KEY_GROUP_LIST;
EXTERN NSString * const QuickJoinOrCreateRoomRequest_KEY_ROOM_SETTINGS;
EXTERN NSString * const QuickJoinOrCreateRoomRequest_KEY_ROOM_TO_LEAVE;

/** The request attempts to find a matching Room to join immediately. If the provided MatchExpression doesn't return any valid match a new Room
 is created with the settings provided and auto-joined.
 
 */
@interface QuickJoinOrCreateRoomRequest : BaseRequest {
	
@private
	MatchExpression* 	_matchExp;
	NSArray* 			_groupList;
	RoomSettings*	 	_roomSettings;
	id<Room>			_roomToLeave;
	
	CreateRoomRequest* 	_createRoomRequest;
}

/**
 @param matchExp a MatchExpression to search for a specifc subset of Rooms
 @param groupList one or more valid group names where to search for Rooms
 @param roomSettings the setting for the Room that will be created if no Rooms match the search criteria
 @param roomToLeave an optional Room to leave when the new Room is joined
 
 @see [ISFSEvents onRoomJoin:]
 @see [ISFSEvents onRoomJoinError:]
 @see [ISFSEvents onRoomAdd:]
 @see [ISFSEvents onRoomCreationError:]
 @see LeaveRoomRequest
 */

+(id) requestWithMatchExpression:(MatchExpression*)matchExp groupList:(NSArray*)groupList roomSettings:(RoomSettings*)settings roomToLeave:(id<Room>)roomToLeave;


/**
 @param matchExp a MatchExpression to search for a specifc subset of Rooms
 @param groupList one or more valid group names where to search for Rooms
 @param roomSettings the setting for the Room that will be created if no Rooms match the search criteria
 
 @see [ISFSEvents onRoomJoin:]
 @see [ISFSEvents onRoomJoinError:]
 @see [ISFSEvents onRoomAdd:]
 @see [ISFSEvents onRoomCreationError:]
 @see LeaveRoomRequest
 */
+(id) requestWithMatchExpression:(MatchExpression*)matchExp groupList:(NSArray*)groupList roomSettings:(RoomSettings*)settings;


@end
