UDP Messenger by Giacomo Furlan.
This software is being distributed under the CC BY 3.0 licence.
You are not allowed to use this source code for pirate purposes.
This software is provided "as-is" and it comes with no warranties.
Minimum: 8
Target: 17
This library aims to send simple text messages to a multicast group just joining a WiFi network (which allows UDP packets transmission).
The message group is identified by a TAG, which is being set when the class is being constructed. It's up to the developer to analyse the packet and do whatever he/she likes.
- Include the library in your Android project
- Extend the UDPMessenger class implementing the abstract getIncomingMessageAnalyseRunnable method. The message to analyse is incomingMessage (type: Message)
- Instantiate an object of the extended UDPMessenger type (now for reference: myExtClassObj).
myExtClassObj.sendMessage("my message here")
- start the receiver:
myExtClassObj.startMessageReceiver()
- analyse the Message incomingMessage in the implemented Runnable getIncomingMessageAnalyseRunnable. Note that this runnable will be run in the main Looper.
- String getTag(): gets the TAG used to identify the multicast group
- String getMessage(): gets the message contained in the packet
- long getEpochTime(): gets the time in epoch format of the message
- InetAddress getSrcIp(): may be null, the address from which the packet is being sent from.
- String toString(): "TAG EPOCH MESSAGE"