Java Reference
In-Depth Information
(a)
(b)
Figure B.7
Running the Presence example: a) Presence2 client and b) Presence client
public void sendMessage(Friend friend)
{
console.println("Sending message #" + numOfMessagesSent + " to " +
friend.getUsername(), Console.GREEN);
//send message to friend
friend.sendMessage(" " + numOfMessagesSent);
console.println("Sent all messages. Waiting for reply...",
Console.WHITE);
}
Sending a message using
friend.sendMessage()
triggers the
friendChatMessageReceived()
event on the receiving end (in our
case, the second instance of the application):
{
public void friendChatMessageReceived(Friend sender, String message)
console.println("Received message " + message, Console.WHITE);
}
For more details on using SNAP Mobile Instant Messaging, please refer
to the
friendchat.jad
and
friendchat2.jad
applications in the
SDK.