|
@@ -32,8 +32,6 @@ import com.dmdirc.parser.common.QueuePriority;
|
32
|
32
|
import com.dmdirc.parser.common.SRVRecord;
|
33
|
33
|
import com.dmdirc.parser.common.SystemEncoder;
|
34
|
34
|
import com.dmdirc.parser.events.ConnectErrorEvent;
|
35
|
|
-import com.dmdirc.parser.events.DataInEvent;
|
36
|
|
-import com.dmdirc.parser.events.DataOutEvent;
|
37
|
35
|
import com.dmdirc.parser.events.DebugInfoEvent;
|
38
|
36
|
import com.dmdirc.parser.events.ErrorInfoEvent;
|
39
|
37
|
import com.dmdirc.parser.events.PingFailureEvent;
|
|
@@ -52,7 +50,6 @@ import com.dmdirc.parser.irc.events.IRCDataOutEvent;
|
52
|
50
|
import com.dmdirc.parser.irc.outputqueue.OutputQueue;
|
53
|
51
|
|
54
|
52
|
import java.io.IOException;
|
55
|
|
-import java.io.PrintWriter;
|
56
|
53
|
import java.net.InetAddress;
|
57
|
54
|
import java.net.Socket;
|
58
|
55
|
import java.net.URI;
|
|
@@ -207,10 +204,8 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
|
207
|
204
|
/** Current Socket State. */
|
208
|
205
|
protected SocketState currentSocketState = SocketState.NULL;
|
209
|
206
|
/**
|
210
|
|
- * The underlying socket used for reading/writing to the IRC server.
|
211
|
|
- * For normal sockets this will be the same as {@link #mySocket} but for SSL
|
212
|
|
- * connections this will be the underlying {@link Socket} while
|
213
|
|
- * {@link #mySocket} will be an {@link SSLSocket}.
|
|
207
|
+ * The underlying socket connected to the IRC server. For SSL connections this socket will be
|
|
208
|
+ * wrapped, and should therefore not be used to send or receive data.
|
214
|
209
|
*/
|
215
|
210
|
private Socket rawSocket;
|
216
|
211
|
/** Used for writing to the server. */
|
|
@@ -803,7 +798,9 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
|
803
|
798
|
*/
|
804
|
799
|
private void handleConnectException(final Exception e, final boolean isUserError) {
|
805
|
800
|
callDebugInfo(DEBUG_SOCKET, "Error Connecting (" + e.getMessage() + "), Aborted");
|
806
|
|
- final ParserError ei = new ParserError(ParserError.ERROR_ERROR + (isUserError ? ParserError.ERROR_USER : 0), "Exception with server socket", getLastLine());
|
|
801
|
+ final ParserError ei = new ParserError(
|
|
802
|
+ ParserError.ERROR_ERROR + (isUserError ? ParserError.ERROR_USER : 0),
|
|
803
|
+ "Exception with server socket", getLastLine());
|
807
|
804
|
ei.setException(e);
|
808
|
805
|
callConnectError(ei);
|
809
|
806
|
|
|
@@ -978,12 +975,12 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
|
978
|
975
|
|
979
|
976
|
@Override
|
980
|
977
|
public void sendRawMessage(final String message) {
|
981
|
|
- doSendString(message, QueuePriority.NORMAL, false);
|
|
978
|
+ sendString(message, QueuePriority.NORMAL, false);
|
982
|
979
|
}
|
983
|
980
|
|
984
|
981
|
@Override
|
985
|
982
|
public void sendRawMessage(final String message, final QueuePriority priority) {
|
986
|
|
- doSendString(message, priority, false);
|
|
983
|
+ sendString(message, priority, false);
|
987
|
984
|
}
|
988
|
985
|
|
989
|
986
|
/**
|
|
@@ -993,7 +990,7 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
|
993
|
990
|
* @return True if line was sent, else false.
|
994
|
991
|
*/
|
995
|
992
|
public boolean sendString(final String line) {
|
996
|
|
- return doSendString(line, QueuePriority.NORMAL, true);
|
|
993
|
+ return sendString(line, QueuePriority.NORMAL, true);
|
997
|
994
|
}
|
998
|
995
|
|
999
|
996
|
/**
|
|
@@ -1017,7 +1014,7 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
|
1017
|
1014
|
* @return True if line was sent, else false.
|
1018
|
1015
|
*/
|
1019
|
1016
|
public boolean sendString(final String line, final QueuePriority priority) {
|
1020
|
|
- return doSendString(line, priority, true);
|
|
1017
|
+ return sendString(line, priority, true);
|
1021
|
1018
|
}
|
1022
|
1019
|
|
1023
|
1020
|
/**
|
|
@@ -1028,12 +1025,23 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
|
1028
|
1025
|
* @param fromParser is this line from the parser? (used for callDataOut)
|
1029
|
1026
|
* @return True if line was sent, else false.
|
1030
|
1027
|
*/
|
1031
|
|
- protected boolean doSendString(final String line, final QueuePriority priority, final boolean fromParser) {
|
|
1028
|
+ protected boolean sendString(final String line, final QueuePriority priority, final boolean fromParser) {
|
1032
|
1029
|
if (out == null || getSocketState() != SocketState.OPEN) {
|
1033
|
1030
|
return false;
|
1034
|
1031
|
}
|
1035
|
1032
|
callDataOut(line, fromParser);
|
1036
|
1033
|
out.sendLine(line, priority);
|
|
1034
|
+ parseOutgoingLine(line);
|
|
1035
|
+
|
|
1036
|
+ return true;
|
|
1037
|
+ }
|
|
1038
|
+
|
|
1039
|
+ /**
|
|
1040
|
+ * Parses a line that has been sent to the server in order to track state.
|
|
1041
|
+ *
|
|
1042
|
+ * @param line The line to be parsed.
|
|
1043
|
+ */
|
|
1044
|
+ private void parseOutgoingLine(final String line) {
|
1037
|
1045
|
final String[] newLine = tokeniseLine(line);
|
1038
|
1046
|
if ("away".equalsIgnoreCase(newLine[0]) && newLine.length > 1) {
|
1039
|
1047
|
myself.setAwayReason(newLine[newLine.length - 1]);
|
|
@@ -1059,8 +1067,6 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
|
1059
|
1067
|
}
|
1060
|
1068
|
}
|
1061
|
1069
|
}
|
1062
|
|
-
|
1063
|
|
- return true;
|
1064
|
1070
|
}
|
1065
|
1071
|
|
1066
|
1072
|
@Override
|
|
@@ -1728,7 +1734,7 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
|
1728
|
1734
|
// Don't attempt to send anything further.
|
1729
|
1735
|
getOutputQueue().clearQueue();
|
1730
|
1736
|
final String output = (reason == null || reason.isEmpty()) ? "QUIT" : "QUIT :" + reason;
|
1731
|
|
- doSendString(output, QueuePriority.IMMEDIATE, true);
|
|
1737
|
+ sendString(output, QueuePriority.IMMEDIATE, true);
|
1732
|
1738
|
// Don't bother queueing anything else.
|
1733
|
1739
|
getOutputQueue().setDiscarding(true);
|
1734
|
1740
|
}
|