0

this is my class

 public class mm {
 public class MessageHandler {
 public HashMap<String, Command> commandMap;
 public MessageHandler() {
 this.commandMap = new HashMap<>();
 commandMap.put("init", new CreateOfferCommand());
 commandMap.put("offer", new CreateAnswerCommand());
 commandMap.put("answer", new SetRemoteSDPCommand());
 commandMap.put("candidate", new AddIceCandidateCommand());
 }
 public Emitter.Listener onMessage = new Emitter.Listener() {
 @Override
 public void call(Object... args) {
 JSONObject data = (JSONObject) args[0];
 try {
 String from = data.getString("from");
 String type = data.getString("type");
 JSONObject payload = null;
 if(!type.equals("init")) {
 payload = data.getJSONObject("payload");
 }
 // if peer is unknown, try to add him
 if(!peers.containsKey(from)) {
 // if MAX_PEER is reach, ignore the call
 int endPoint = findEndPoint();
 if(endPoint != MAX_PEER) {
 Peer peer = addPeer(from, endPoint);
 peer.pc.addStream(localMS);
 commandMap.get(type).execute(from, payload);
 }
 } else {
 commandMap.get(type).execute(from, payload);
 }
 } catch (JSONException e) {
 e.printStackTrace();
 }
 }
 };
 public Emitter.Listener onId = new Emitter.Listener() {
 @Override
 public void call(Object... args) {
 String id = (String) args[0];
 mListener.onCallReady(id);
 }
 };
 public Emitter.Listener onCall = new Emitter.Listener() {
 @Override
 public void call(Object... args) {
 String id = (String) args[0];
 mListener.onCalling(id);
 }
 };
}
 ......................
 .........
}

and when i call the inner class from another class its give me an enclosing class

 mm.MessageHandler messageHandler = new mm.MessageHandler();

when i make inner class messageHandler a static the error gone but its shown anothe error inside inner class so can i call the inner class without make it static ?

asked Jun 19, 2016 at 16:06
0

1 Answer 1

1
mm n = new mm(); 
mm.MessageHandler messageHandler = n.new MessageHandler();

or use static in your inner class

hope that's help

answered Jun 19, 2016 at 17:27
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.