Skip to content

Commit

Permalink
Merge pull request #461 from greboid/dev2
Browse files Browse the repository at this point in the history
Add a getNickname to Connection.
  • Loading branch information
csmith committed Jan 12, 2015
2 parents d6de7a6 + 69380fe commit 596d2e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/com/dmdirc/Server.java
Expand Up @@ -43,6 +43,7 @@
import com.dmdirc.parser.common.IgnoreList;
import com.dmdirc.parser.common.ParserError;
import com.dmdirc.parser.common.ThreadedParser;
import com.dmdirc.parser.interfaces.ClientInfo;
import com.dmdirc.parser.interfaces.EncodingParser;
import com.dmdirc.parser.interfaces.Parser;
import com.dmdirc.parser.interfaces.ProtocolDescription;
Expand Down Expand Up @@ -1072,6 +1073,11 @@ public void setNickname(final String nickname) {
parser.map(Parser::getLocalClient).ifPresent(c -> c.setNickname(nickname));
}

@Override
public Optional<String> getNickname() {
return parser.map(Parser::getLocalClient).map(ClientInfo::getNickname);
}

/**
* Utility method to get a result from the parser while holding the {@link #parserLock}
* read lock.
Expand Down
7 changes: 7 additions & 0 deletions src/com/dmdirc/interfaces/Connection.java
Expand Up @@ -410,4 +410,11 @@ public interface Connection {
*/
void setNickname(final String nickname);

/**
* Returns the current nickname for this connection.
*
* @return Current nickname, or an empty if not present
*/
Optional<String> getNickname();

}

0 comments on commit 596d2e0

Please sign in to comment.