这是我的班级
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);
}
};
}
......................
.........
}
当我从另一个类调用内部类时,它给我一个封闭的类
mm.MessageHandler messageHandler = new mm.MessageHandler();
当我使内部类messageHandler成为静态时,错误消失了,但它在内部类中显示了错误,所以我可以调用内部类而不使其静态吗?
答案 0 :(得分:1)
ColorExtractor.Analyse()
或在内部类中使用static
希望得到帮助