Skip to content

Commit

Permalink
enable secure connection
Browse files Browse the repository at this point in the history
  • Loading branch information
derrick56007 authored and ra1u committed Feb 19, 2021
1 parent 8c858b6 commit d8fa9ac
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions lib/connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,58 +7,66 @@
* Luka Rahne
*/


part of redis;

/// Class for server connection on server
class RedisConnection{
class RedisConnection {
Socket _socket = null;
LazyStream _stream = null;
Future _future = new Future.value();
RedisParser parser = new RedisParser();


/// connect on Redis server as client
Future<Command> connect(host, port) {
return Socket.connect(host, port).then((Socket sock) {
_socket = sock;
disable_nagle(true);
_stream = new LazyStream.fromstream(_socket);
return new Command(this);
});
}

/// connect on Redis server as client
Future<Command> connect(host, port){
return Socket.connect(host, port)
.then((Socket sock){
Future<Command> connectSecure(host, port) {
return SecureSocket.connect(host, port).then((SecureSocket sock) {
_socket = sock;
disable_nagle(true);
_stream =new LazyStream.fromstream(_socket);
_stream = new LazyStream.fromstream(_socket);
return new Command(this);
});
}

/// close connection to Redis server
Future close(){
Future close() {
_stream.close();
return _socket.close();
}

//this doesnt send anything
//it just wait something to come from socket
//it parse it and execute future
Future _senddummy(){
Future _senddummy() {
_future = _future.then((_) {
return RedisParser.parseredisresponse(_stream);
return RedisParser.parseredisresponse(_stream);
});
return _future;
}

// return future that complets
// when all prevous _future finished
Future _getdummy(){
_future = _future.then((_){
return "dummy data";
Future _getdummy() {
_future = _future.then((_) {
return "dummy data";
});
return _future;
}
Future _sendraw(List data){

Future _sendraw(List data) {
_socket.add(data);
return _senddummy();
}
void disable_nagle(bool v){
_socket.setOption(SocketOption.TCP_NODELAY,v);

void disable_nagle(bool v) {
_socket.setOption(SocketOption.TCP_NODELAY, v);
}
}

0 comments on commit d8fa9ac

Please sign in to comment.