1 /*
2  * Copyright (C) 2019, HuntLabs
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 module hunt.database.driver.mysql.impl.MySQLSocketConnection;
19 
20 
21 import hunt.database.base.AsyncResult;
22 import hunt.database.base.Common;
23 import hunt.database.base.impl.Connection;
24 import hunt.database.base.impl.SocketConnectionBase;
25 import hunt.database.base.impl.command.CommandResponse;
26 import hunt.database.base.impl.command.InitCommand;
27 
28 import hunt.io.ByteBuffer;
29 import hunt.io.BufferUtils;
30 import hunt.collection.Map;
31 import hunt.Exceptions;
32 import hunt.logging;
33 import hunt.net.AbstractConnection;
34 import hunt.net.Exceptions;
35 import hunt.util.Common;
36 
37 /**
38  * @author <a href="mailto:julien@julienviet.com">Julien Viet</a>
39  */
40 class MySQLSocketConnection : SocketConnectionBase {
41 
42     this(AbstractConnection socket,
43             bool cachePreparedStatements,
44             int preparedStatementCacheSize,
45             int preparedStatementCacheSqlLimit) {
46 
47         super(socket, cachePreparedStatements, preparedStatementCacheSize, 
48                 preparedStatementCacheSqlLimit, 1);
49     }
50 
51     // override
52     // void initialization() {
53     //     super.initialization();
54     // }
55 
56     void sendStartupMessage(string username, string password, string database, Map!(string, string) properties, 
57             ResponseHandler!(DbConnection) completionHandler) {
58         InitCommand cmd = new InitCommand(this, username, password, database, properties);
59         cmd.handler = completionHandler;
60         version(HUNT_DB_DEBUG) {
61             trace("Sending InitCommand");
62         }
63         schedule(cmd);
64     }
65 }