package io.vertx.mysqlclient.impl;
import io.netty.channel.ChannelPipeline;
import io.vertx.core.Context;
import io.vertx.core.Handler;
import io.vertx.core.impl.NetSocketInternal;
import io.vertx.mysqlclient.impl.codec.MySQLCodec;
import io.vertx.sqlclient.impl.Connection;
import io.vertx.sqlclient.impl.SocketConnectionBase;
import io.vertx.sqlclient.impl.command.CommandResponse;
import io.vertx.sqlclient.impl.command.InitCommand;
import java.util.Map;
public class MySQLSocketConnection extends SocketConnectionBase {
private MySQLCodec codec;
public MySQLSocketConnection(NetSocketInternal socket,
boolean cachePreparedStatements,
int preparedStatementCacheSize,
int preparedStatementCacheSqlLimit,
Context context) {
super(socket, cachePreparedStatements, preparedStatementCacheSize, preparedStatementCacheSqlLimit, 1, context);
}
void sendStartupMessage(String username, String password, String database, Map<String, String> properties, Handler<? super CommandResponse<Connection>> completionHandler) {
InitCommand cmd = new InitCommand(this, username, password, database, properties);
cmd.handler = completionHandler;
schedule(cmd);
}
@Override
public void init() {
codec = new MySQLCodec();
ChannelPipeline pipeline = socket.channelHandlerContext().pipeline();
pipeline.addBefore("handler", "codec", codec);
super.init();
}
}