forked from karelia/MockServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKMSRegExResponder.h
57 lines (34 loc) · 1.56 KB
/
KMSRegExResponder.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// Created by Sam Deane on 06/11/2012.
// Copyright 2012 Karelia Software. All rights reserved.
//
#import "KMSResponder.h"
/**
Object which responds to incoming data by outputting a list of commands.
This class works by matching the input against a list of regular expression patterns.
Commands, in this context, means an array of NSString, NSData, or NSNumber
objects.
NSData objects are sent back directly as output.
NSString objects are also sent back, except for the constant CloseCommand string, which closes the connection instead.
NSNumber objects are interpreted as times, in seconds, to pause before sending back further output.
*/
@interface KMSRegExResponder : KMSResponder
/**
Return a new responder object, using an array of responses.
The responses consist of an array of arrays. Each of the inner arrays is in this format:
@[pattern, command, command...]
The pattern is a regular expression which is matched against input received by the server.
@param responses An array of patterns and commands.
@return The new responder object.
*/
+ (KMSRegExResponder*)responderWithResponses:(NSArray*)responses;
/**
Initialise a new responder object, using an array of responses.
The responses consist of an array of arrays. Each of the inner arrays is in this format:
@[pattern, command, command...]
The pattern is a regular expression which is matched against input received by the server.
@param responses An array of patterns and commands.
@return The new responder object.
*/
- (id)initWithResponses:(NSArray*)responses;
@end