MaDKit forum

Welcome All !
Please, use explicit topic names when creating new threads. Thanks.

You are not logged in.

#1 2017-03-10 03:36:21

badhic
Member
Registered: 2015-05-29
Posts: 4

How to know message type

Hello,
Please, is there a way to know the type of a received message, and so is it possible to use different types of messages at the same time.
thank you for help.

Offline

#2 2017-03-10 09:51:12

fmichel
Administrator
From: Montpellier
Registered: 2009-03-24
Posts: 172
Website

Re: How to know message type

Hello,

Since an agent may send and receive any kind of messages, you have to test that the message is of a particular expected type. Example:

			Message m = waitNextMessage();
			if (m instanceof GUIMessage) {
				treat((GUIMessage) m);
			}
			else
				if (m instanceof KernelMessage) {
					treat((KernelMessage) m);
				}
				else
					if (logger != null)
						logger.warning("I received a message that I do not understand. Discarding "
								+ m);
		}

Therefore it is of course possible to use different types of messages at the same time.

Offline

#3 2017-03-10 11:36:35

badhic
Member
Registered: 2015-05-29
Posts: 4

Re: How to know message type

Thank you !
you save me a lot of time

Offline

Board footer