@@ -32,22 +32,26 @@ class Server extends EventEmitter
32
32
private $ protocol ;
33
33
private $ business ;
34
34
private $ clients ;
35
- private $ database ;
35
+ private $ databases ;
36
36
37
37
public function __construct (ServerSocket $ socket , LoopInterface $ loop , ProtocolFactory $ protocol = null , Invoker $ business = null )
38
38
{
39
39
if ($ protocol === null ) {
40
40
$ protocol = new ProtocolFactory ();
41
41
}
42
42
43
- $ this ->database = new Storage ();
43
+ $ this ->databases = array (
44
+ new Storage ('0 ' ),
45
+ new Storage ('1 ' ),
46
+ );
47
+ $ db = reset ($ this ->databases );
44
48
45
49
if ($ business === null ) {
46
50
$ business = new Invoker ($ protocol ->createSerializer ());
47
51
$ business ->addCommands (new Business \Connection ());
48
- $ business ->addCommands (new Business \Keys ($ this -> database ));
49
- $ business ->addCommands (new Business \Lists ($ this -> database ));
50
- $ business ->addCommands (new Business \Strings ($ this -> database ));
52
+ $ business ->addCommands (new Business \Keys ($ db ));
53
+ $ business ->addCommands (new Business \Lists ($ db ));
54
+ $ business ->addCommands (new Business \Strings ($ db ));
51
55
$ business ->renameCommand ('x_echo ' , 'echo ' );
52
56
}
53
57
@@ -70,7 +74,7 @@ public function handleConnection(Connection $connection)
70
74
$ parser = new RequestParser ();
71
75
$ that = $ this ;
72
76
73
- $ client = new Client ($ connection , $ this ->business , $ this ->database );
77
+ $ client = new Client ($ connection , $ this ->business , reset ( $ this ->databases ) );
74
78
$ this ->clients ->attach ($ client );
75
79
76
80
$ connection ->on ('data ' , function ($ data ) use ($ parser , $ that , $ client ) {
0 commit comments