2014-06-11 23:40:19 +02:00
|
|
|
/*
|
2015-08-08 19:36:14 +02:00
|
|
|
* Copyright (c) 2012-2015 The original author or authors
|
2014-06-11 23:40:19 +02:00
|
|
|
* ------------------------------------------------------
|
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
|
* and Apache License v2.0 which accompanies this distribution.
|
|
|
|
|
*
|
|
|
|
|
* The Eclipse Public License is available at
|
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
|
*
|
|
|
|
|
* The Apache License v2.0 is available at
|
|
|
|
|
* http://www.opensource.org/licenses/apache2.0.php
|
|
|
|
|
*
|
|
|
|
|
* You may elect to redistribute this code under either of these licenses.
|
|
|
|
|
*/
|
2015-11-20 20:54:27 +01:00
|
|
|
package io.moquette.server;
|
2012-07-11 23:44:05 +02:00
|
|
|
|
2016-01-17 11:11:36 +01:00
|
|
|
import io.netty.channel.Channel;
|
|
|
|
|
|
2012-07-11 23:44:05 +02:00
|
|
|
/**
|
2015-11-10 22:24:35 +01:00
|
|
|
* Value object to maintain the information of single connection, like ClientID, IoSession,
|
|
|
|
|
* and other clean session fla.
|
2012-07-11 23:44:05 +02:00
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @author andrea
|
|
|
|
|
*/
|
|
|
|
|
public class ConnectionDescriptor {
|
|
|
|
|
|
2015-11-10 22:24:35 +01:00
|
|
|
public final String clientID;
|
2016-01-24 19:17:31 +01:00
|
|
|
public final Channel channel;
|
2015-11-10 22:24:35 +01:00
|
|
|
public final boolean cleanSession;
|
2012-07-11 23:44:05 +02:00
|
|
|
|
2016-01-17 11:11:36 +01:00
|
|
|
public ConnectionDescriptor(String clientID, Channel session, boolean cleanSession) {
|
2015-11-10 22:24:35 +01:00
|
|
|
this.clientID = clientID;
|
2016-01-24 19:17:31 +01:00
|
|
|
this.channel = session;
|
2015-11-10 22:24:35 +01:00
|
|
|
this.cleanSession = cleanSession;
|
2012-07-11 23:44:05 +02:00
|
|
|
}
|
2013-12-14 12:33:38 +01:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String toString() {
|
2015-11-10 22:24:35 +01:00
|
|
|
return "ConnectionDescriptor{" + "clientID=" + clientID + ", cleanSession=" + cleanSession + '}';
|
2013-12-14 12:33:38 +01:00
|
|
|
}
|
2015-12-27 13:19:16 +01:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean equals(Object o) {
|
|
|
|
|
if (this == o) return true;
|
|
|
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
|
|
|
|
|
|
|
|
ConnectionDescriptor that = (ConnectionDescriptor) o;
|
|
|
|
|
|
|
|
|
|
if (clientID != null ? !clientID.equals(that.clientID) : that.clientID != null) return false;
|
2016-01-24 19:17:31 +01:00
|
|
|
return !(channel != null ? !channel.equals(that.channel) : that.channel != null);
|
2015-12-27 13:19:16 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int hashCode() {
|
|
|
|
|
int result = clientID != null ? clientID.hashCode() : 0;
|
2016-01-24 19:17:31 +01:00
|
|
|
result = 31 * result + (channel != null ? channel.hashCode() : 0);
|
2015-12-27 13:19:16 +01:00
|
|
|
return result;
|
|
|
|
|
}
|
2012-07-11 23:44:05 +02:00
|
|
|
}
|