ymsg.network.event
Class SessionNotifyEvent

Object
  extended byEventObject
      extended bySessionEvent
          extended bySessionNotifyEvent
All Implemented Interfaces:
Serializable

public class SessionNotifyEvent
extends SessionEvent

Represents an incoming notify message event. There are two noteworthy notifications: the first (and by far the most common) is TYPING events, which are received when a remote user is in the process of sending a message to our client. The second is GAME events. (The current jYMSG API doesn't support games.)

There are two ways of determining the type of notification. The first is to study the type field and compare it to the Stringvalues in StatusConstants: NOTIFY_TYPING and NOTIFY_GAME. The second is to call either of the boolean methods, isTyping or isGame.

The mode determines whether the notification is on or off. 0 meaning off and 1 meaning on. Yahoo will send 'on' packets when a an 'action' starts, and 'off' when it finishs (in the case of typing, 'off' will be sent if there is a suitable pause in typing or the message is actually transmitted. When typing restarts, 'on' will be sent).

For packets of a game type, the game field will contain the name of the game.

Note: Yahoo sends the game name encoded as a regular text message, and jYMSG API uses the message field to store it. getGame is actually just actually another name for getMessage.

  getTo getFrom getMessage getType getMode
notifyReceived y y y y y

Since:
1.0
See Also:
Serialized Form

Field Summary
 
Fields inherited from class EventObject
source
 
Constructor Summary
SessionNotifyEvent(Object o, String t, String f, String m, String ty, String md)
          Create a new instance.
 
Method Summary
 String getGame()
          Returns the game name if this is a game notification, otherwise null.
 int getMode()
          Returns the notification mode.
 String getType()
          Returns the notification type, TYPING, GAME, etc.
 boolean isGame()
          Returns true if notification is game type.
 boolean isTyping()
          Returns true if notification is typing type.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class SessionEvent
getFrom, getMessage, getStatus, getTimestamp, getTo
 
Methods inherited from class EventObject
getSource
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SessionNotifyEvent

public SessionNotifyEvent(Object o,
                          String t,
                          String f,
                          String m,
                          String ty,
                          String md)
Create a new instance. API users should not call this directly. The API itself will create its own events.

Parameters:
o - source of event (Session)
t - to (Yahoo id)
f - from (Yahoo id)
m - message (ASCII or UTF-8)
ty - type (TYPING/GAME)
md - mode (0 or 1)
Since:
1.0
Method Detail

getMode

public int getMode()
Returns the notification mode. Zero is off, one is on.

Returns:
mode as integer
Since:
1.0

getType

public String getType()
Returns the notification type, TYPING, GAME, etc. See StatusConstants.

Returns:
type string
Since:
1.0
See Also:
isTyping(), isGame()

getGame

public String getGame()
Returns the game name if this is a game notification, otherwise null. (Actually a wrapper for getMessage.)

Returns:
game name
Since:
1.0

isTyping

public boolean isTyping()
Returns true if notification is typing type.

Returns:
true if typing
Since:
1.0
See Also:
getType()

isGame

public boolean isGame()
Returns true if notification is game type.

Returns:
true if game
Since:
1.0
See Also:
getType()

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class SessionEvent
Returns:
object as a string
Since:
1.0