const int kSizePacketLenMax = 2;
// The current MCS protocol version.
-// TODO(zea): bump to 41 once the server supports it.
-const int kMCSVersion = 38;
+const int kMCSVersion = 41;
} // namespace
const ProtoSentCallback& write_callback,
const ConnectionChangedCallback& connection_callback)
: read_timeout_(read_timeout),
+ socket_(NULL),
handshake_complete_(false),
message_tag_(0),
message_size_(0),
Login(login_request);
}
+void ConnectionHandlerImpl::Reset() {
+ CloseConnection();
+}
+
bool ConnectionHandlerImpl::CanSendMessage() const {
return handshake_complete_ && output_stream_.get() &&
output_stream_->GetState() == SocketOutputStream::EMPTY;
CodedInputStream coded_input_stream(input_stream_.get());
coded_input_stream.ReadRaw(&version, 1);
}
- if (version < kMCSVersion) {
+ // TODO(zea): remove this when the server is ready.
+ if (version < kMCSVersion && version != 38) {
LOG(ERROR) << "Invalid GCM version response: " << static_cast<int>(version);
connection_callback_.Run(net::ERR_FAILED);
return;
void ConnectionHandlerImpl::CloseConnection() {
DVLOG(1) << "Closing connection.";
read_timeout_timer_.Stop();
- socket_->Disconnect();
+ if (socket_)
+ socket_->Disconnect();
+ socket_ = NULL;
input_stream_.reset();
output_stream_.reset();
weak_ptr_factory_.InvalidateWeakPtrs();