浏览代码

Merge branch 'master' of https://github.com/DMDirc/Parser

pull/164/head
Greg Holmes 7 年前
父节点
当前提交
e591040c2f

+ 16
- 10
irc/src/main/java/com/dmdirc/parser/irc/IRCParser.java 查看文件

212
      * wrapped, and should therefore not be used to send or receive data.
212
      * wrapped, and should therefore not be used to send or receive data.
213
      */
213
      */
214
     private Socket rawSocket;
214
     private Socket rawSocket;
215
+    /** The socket connected to the IRC server, used for sending or receiving data. */
216
+    private Socket socket;
215
     /** Used for writing to the server. */
217
     /** Used for writing to the server. */
216
     private OutputQueue out;
218
     private OutputQueue out;
217
     /** The encoder to use to encode incoming lines. */
219
     /** The encoder to use to encode incoming lines. */
309
      *
311
      *
310
      * @param queue The queue to be added.
312
      * @param queue The queue to be added.
311
      */
313
      */
312
-    public void setOutputQueue(final OutputQueue queue) {
314
+    public void setOutputQueue(final OutputQueue queue) throws IOException {
313
         checkNotNull(queue);
315
         checkNotNull(queue);
314
         out.clearQueue();
316
         out.clearQueue();
317
+
318
+        if (socket != null) {
319
+            queue.setOutputStream(socket.getOutputStream());
320
+        }
321
+
315
         out = queue;
322
         out = queue;
316
     }
323
     }
317
 
324
 
750
 
757
 
751
         rawSocket = getSocketFactory().createSocket(connectUri.getHost(), connectUri.getPort());
758
         rawSocket = getSocketFactory().createSocket(connectUri.getHost(), connectUri.getPort());
752
 
759
 
753
-        final Socket mySocket;
754
         if (getURI().getScheme().endsWith("s")) {
760
         if (getURI().getScheme().endsWith("s")) {
755
             callDebugInfo(DEBUG_SOCKET, "Server is SSL.");
761
             callDebugInfo(DEBUG_SOCKET, "Server is SSL.");
756
 
762
 
762
             sc.init(myKeyManagers, myTrustManager, new SecureRandom());
768
             sc.init(myKeyManagers, myTrustManager, new SecureRandom());
763
 
769
 
764
             final SSLSocketFactory socketFactory = sc.getSocketFactory();
770
             final SSLSocketFactory socketFactory = sc.getSocketFactory();
765
-            mySocket = socketFactory.createSocket(rawSocket, getURI().getHost(), getURI()
771
+            socket = socketFactory.createSocket(rawSocket, getURI().getHost(), getURI()
766
                     .getPort(), false);
772
                     .getPort(), false);
767
 
773
 
768
             // Manually start a handshake so we get proper SSL errors here,
774
             // Manually start a handshake so we get proper SSL errors here,
769
             // and so that we can control the connection timeout
775
             // and so that we can control the connection timeout
770
-            final int timeout = mySocket.getSoTimeout();
771
-            mySocket.setSoTimeout(10000);
772
-            ((SSLSocket) mySocket).startHandshake();
773
-            mySocket.setSoTimeout(timeout);
776
+            final int timeout = socket.getSoTimeout();
777
+            socket.setSoTimeout(10000);
778
+            ((SSLSocket) socket).startHandshake();
779
+            socket.setSoTimeout(timeout);
774
 
780
 
775
             currentSocketState = SocketState.OPENING;
781
             currentSocketState = SocketState.OPENING;
776
         } else {
782
         } else {
777
-            mySocket = rawSocket;
783
+            socket = rawSocket;
778
         }
784
         }
779
 
785
 
780
         callDebugInfo(DEBUG_SOCKET, "\t-> Opening socket output stream PrintWriter");
786
         callDebugInfo(DEBUG_SOCKET, "\t-> Opening socket output stream PrintWriter");
781
-        out.setOutputStream(mySocket.getOutputStream());
787
+        out.setOutputStream(socket.getOutputStream());
782
         out.setQueueEnabled(true);
788
         out.setQueueEnabled(true);
783
         currentSocketState = SocketState.OPEN;
789
         currentSocketState = SocketState.OPEN;
784
         callDebugInfo(DEBUG_SOCKET, "\t-> Opening socket input stream BufferedReader");
790
         callDebugInfo(DEBUG_SOCKET, "\t-> Opening socket input stream BufferedReader");
785
-        in = new IRCReader(mySocket.getInputStream(), encoder);
791
+        in = new IRCReader(socket.getInputStream(), encoder);
786
         callDebugInfo(DEBUG_SOCKET, "\t-> Socket Opened");
792
         callDebugInfo(DEBUG_SOCKET, "\t-> Socket Opened");
787
     }
793
     }
788
 
794
 

+ 7
- 1
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessJoin.java 查看文件

193
         } else {
193
         } else {
194
             // Some kind of failed to join, pop the pending join queues.
194
             // Some kind of failed to join, pop the pending join queues.
195
             final PendingJoin pendingJoin = pendingJoins.poll();
195
             final PendingJoin pendingJoin = pendingJoins.poll();
196
-            callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Failed to join channel (" + sParam + ") - Skipping " + pendingJoin.getChannel() + " (" + pendingJoin.getKey() + ")");
196
+            if (pendingJoin != null && parser.getStringConverter().equalsIgnoreCase(pendingJoin.getChannel(), sParam)) {
197
+                callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Failed to join channel (" + sParam + ") - Skipping " + pendingJoin.getChannel() + " (" + pendingJoin.getKey() + ")");
198
+            } else {
199
+                // Out of sync, clear
200
+                callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Failed to join channel (" + sParam + ") - pending join keys out of sync (Got: " + (pendingJoin == null ? pendingJoin : pendingJoin.getChannel()) + ", Wanted: " + sParam + ") - Clearing.");
201
+                pendingJoins.clear();
202
+            }
197
         }
203
         }
198
     }
204
     }
199
 
205
 

正在加载...
取消
保存