0

I have 1 outer class with 1 inner class like this:

public class Outer extends PircBot { 
...
public class Inner extends SessionAdapter { 
...    
}
}

Inside that Inner class I am trying to invoke a method called sendMessage(..) which is inside PircBot (and not in Outer class. But of course I know all fields in Outer and Pircbot classes are inherited in the Inner class):

@Override
public void messageReceived(SessionEvent event) { //This method is inside SessionAdapter class which I am extending in my Inner class
Outer.this.sendMessage(event.getMessage()); //This method is inside Pircbot class which I am extending in my Outer class
}

I know for a fact that sendMessage(..) method is called. But for some reason I don't see that message on Twitch chat (This program sends chat messages to Twitch Chat. Those chat messages are received from the Yahoo Chat Messenger from my Phone when I type them). Can anyone see what is wrong with my code?

halfer
  • 19,824
  • 17
  • 99
  • 186
Faraz
  • 6,025
  • 5
  • 31
  • 88
  • If you know for a fact that sendMessage is called, then your problem probably lies in the sendMessage method (which you didn't post). Which makes it difficult to help. – Mark Jul 26 '16 at 08:59
  • Okay I read this and you can close this as far as I'm concerned, but I should mention I'm not the one who favorited this question, so there might be somebody else trying to find an answer to this. Thanks for the consideration though. – Mark Jul 26 '16 at 10:45
  • If you discover the answer, please add the answer to an answer block. Please do not mangle the title with [solved], and please do not append the answer to the question - we prefer questions and answers to be clearly delineated here, not least to improve the data supplied in the SE API. Would you edit? Thanks! – halfer Jul 28 '16 at 21:44
  • Thanks for adding an answer! – halfer Aug 03 '16 at 08:50

1 Answers1

1

This is what I did. I changed the position of the instantiation of inner class (from inside the default outer constructor to instance variable). Like this:

From

public class Outer extends PircBot { 
private int x;
public Outer(){
x = 5;
Inner n = new Inner(); //Instantiation inside Outer class's default constructor
}
public class Inner extends SessionAdapter { 
...    
}
}

To

public class Outer extends PircBot { 
private int x;
Inner n = new Inner(); //Now instantiation is outside constructor
public Outer(){
x = 5;
//no more instantiation inside constructor 
}
public class Inner extends SessionAdapter { 
...    
}
}

Also, it may have been a twitch thing. Sometimes the capitalization of channel names doesn't work. It requires capitalization of letters in certain way. So I changed the capitalization of letters in a String (weird but whatever).

Faraz
  • 6,025
  • 5
  • 31
  • 88