home *** CD-ROM | disk | FTP | other *** search
- import java.io.DataInputStream;
- import java.io.IOException;
-
- class StreamConnector implements Runnable {
- Streamable stream;
- IRCSession session;
- // $FF: renamed from: t java.lang.Thread
- Thread field_0;
-
- public StreamConnector(DataInputStream var1, IRCSession var2, String var3, int var4) {
- this.session = var2;
- if (var4 > 0) {
- try {
- this.stream = (Streamable)Class.forName("HTTPStream").newInstance();
- this.stream.init(var3, var4);
- } catch (Exception var5) {
- this.stream = null;
- }
- } else {
- this.stream = new IOStream(var1);
- }
-
- this.field_0 = new Thread(this);
- this.field_0.start();
- }
-
- public void send(String var1) throws IOException {
- this.stream.send(var1);
- }
-
- public void run() {
- try {
- while(this.session != null && this.field_0 != null) {
- String var1 = this.stream.receive();
- if (var1 != null) {
- try {
- this.session.HandleServerMessage(var1);
- } catch (Exception var3) {
- System.out.println("Warning: Problem handling message:" + var3);
- ((Throwable)var3).printStackTrace();
- System.out.println("attempting to continue ...");
- }
- continue;
- }
- }
- } catch (Exception var4) {
- System.out.println("StreamConnector:");
- ((Throwable)var4).printStackTrace();
- }
-
- if (this.session != null) {
- this.session.HandleServerMessage(":client 444 parachat : Network connection closed");
- }
-
- this.disconnect();
- }
-
- public String connect() {
- return this.stream != null ? this.stream.connect() : null;
- }
-
- public void disconnect() {
- try {
- this.session = null;
- if (this.field_0 != null && Thread.currentThread() != this.field_0) {
- this.field_0.stop();
- }
-
- this.field_0 = null;
- if (this.stream != null) {
- this.stream.disconnect();
- }
-
- this.stream = null;
- } catch (Exception var1) {
- }
- }
- }
-