현재 JADE를 사용하는 주제 기반 통신을 사용하고 있습니다. jade.core.messaging.TopicManagementFEService
을 사용하여 JADE 에이전트를 등록 할 수 있으므로 동일한 플랫폼의 주 컨테이너에 연결할 수 있습니다.JADE를 통해 안드로이드에서 ACLMessage를 수신 할 수 없습니다.
세부 사항은 다음과 같습니다 :
- 홈페이지-컨테이너 : 주 - 컨테이너를 호스팅하는 간단한 램프/WAMP 서버.
- 클라이언트 : 주 컨테이너에 연결하는 Android 에뮬레이터 (테스트 목적). 현재
,
- 서버는
- 안드로이드 에뮬레이터가 성공적으로 메인 컨테이너에 연결되는 주요 컨테이너 시작은 (에이전트가 주제 MGMT 서비스와 함께 생성 가능)
- 서버 기반 보내는 메시지입니다 특정 주제에 대해.
등록 된 주제가 양쪽에서 동일하지만 내 안드로이드 클라이언트는이 메시지를받을 수 없습니다!
당신은 아래의 코드를 볼 수 있습니다는 :
Server Side:
TopicManagementHelper topicHelper = (TopicManagementHelper) getHelper(TopicManagementHelper.SERVICE_NAME);
final AID sensorTopic = topicHelper.createTopic("JADE");
topicHelper.register(sensorTopic);
addBehaviour(new TickerBehaviour(this, TIMER_VALUE_IN_MILLISECONDS) {
private static final long serialVersionUID = -2567778187494378326L;
public void onTick() {
ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
msg.addReceiver(eventTopic);
msg.setContent(eventValue);
myAgent.send(msg);
}
});
Android Side:
// Registering on Android Side as well
TopicManagementHelper topicHelper = (TopicManagementHelper) getHelper(TopicManagementHelper.SERVICE_NAME);
topic = topicHelper.createTopic("JADE"); // See, same topic!
topicHelper.register(topic);
behaviour = new myBehaviour(this, TIMER_VALUE_IN_MILLISECONDS, topic);
addBehaviour(behaviour);
private class myBehaviour extends TickerBehaviour {
private static final long serialVersionUID = 4782913834042415090L;
AID topic;
Agent agent;
MessageTemplate tpl;
public myBehaviour(Agent a, long period, AID topic) {
super(a, period);
this.agent = a;
this.topic = topic;
}
public void onTick() {
tpl = MessageTemplate.MatchTopic(topic);
ACLMessage msg = receive(tpl);
if (msg != null) {
logger.log(Level.INFO, "Agent "+ agent.getLocalName() +
": Message about topic "+ topic.getLocalName() +" received. \n" +
"Content is " + msg.getContent());
data = msg.getContent();
} else {
logger.log(Level.INFO, "In here..."); // Always executes only this code!
block();
}
}
}
어디에서 잘못 여기에 갈거야? 안드로이드 측에서는 항상 else
부분을 실행하는데, 수신 된 메시지가 NULL이라는 것은 명백합니다!
질문에 답변 해주세요. 안드로이드 장치로 옥 서버 (에이전트 플랫폼)를 시작할 수 있습니까? 할 수 있다면 어떻게 할 수 있을까요? –