JXTA

net.jxta.instantp2p
Class Chat

java.lang.Object
  |
  +--net.jxta.instantp2p.Chat
Direct Known Subclasses:
GroupChat

public class Chat
extends java.lang.Object
implements PeerListener

Chat utility in InstantP2P: send and receive message from other users.


Field Summary
static int CHAT_ERROR
           
static java.lang.String CHATNAMETAG
           
protected  net.jxta.instantp2p.Chat.ChatServer chatServer
          The thread that runs the actual chatting procedure
protected  net.jxta.peergroup.PeerGroup group
          The current peer group
static int HUNKYDORY
           
protected  MessageBoard messageBoard
          The MessageBoard intance to use for display
protected  java.lang.String myName
          The name used as a handle for this chat
protected  net.jxta.protocol.PipeAdvertisement myPipeAdvt
          The PipeAdvertisment pertaining to the pipe over which the chat is conducted
protected  net.jxta.pipe.OutputPipe outputPipe
          The pipe to which we write outgoing messages
protected  net.jxta.pipe.Pipe pipes
          The Pipe service to use
protected static int PipeTimeout
           
protected  boolean secured
          Is this a secure chat - default is false
 
Constructor Summary
Chat(net.jxta.peergroup.PeerGroup group, MessageBoard messageBoard)
          Chat Constructor
 
Method Summary
 void groupChanged(net.jxta.peergroup.PeerGroup group)
          groupChanged - acts on change of peer group
 int login(java.lang.String name, boolean secured)
           
 int logout()
          logout a user
 void peerChanged(net.jxta.protocol.PeerGroupAdvertisement pgAdv)
          peerChanged - acts on change of peer for chat
 net.jxta.protocol.PipeAdvertisement registerUser(java.lang.String name)
          Registers a new user.
 int sendMessage(java.lang.String message)
          Sends messages to the receiver end
 int sendMessageToPeers(java.lang.String message)
          sendMessageToPeers - sends message to listening peer(s).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myPipeAdvt

protected net.jxta.protocol.PipeAdvertisement myPipeAdvt
The PipeAdvertisment pertaining to the pipe over which the chat is conducted

CHATNAMETAG

public static final java.lang.String CHATNAMETAG

group

protected net.jxta.peergroup.PeerGroup group
The current peer group

messageBoard

protected MessageBoard messageBoard
The MessageBoard intance to use for display

pipes

protected net.jxta.pipe.Pipe pipes
The Pipe service to use

myName

protected java.lang.String myName
The name used as a handle for this chat

outputPipe

protected net.jxta.pipe.OutputPipe outputPipe
The pipe to which we write outgoing messages

HUNKYDORY

public static final int HUNKYDORY

CHAT_ERROR

public static final int CHAT_ERROR

PipeTimeout

protected static final int PipeTimeout

chatServer

protected net.jxta.instantp2p.Chat.ChatServer chatServer
The thread that runs the actual chatting procedure

secured

protected boolean secured
Is this a secure chat - default is false
Constructor Detail

Chat

public Chat(net.jxta.peergroup.PeerGroup group,
            MessageBoard messageBoard)
Chat Constructor
Parameters:
PeerGroup - group - chat group
MessageBoard - messageBoard - to display messages
Method Detail

groupChanged

public void groupChanged(net.jxta.peergroup.PeerGroup group)
groupChanged - acts on change of peer group
Specified by:
groupChanged in interface PeerListener
Parameters:
PeerGroup - group - changed group object currently, Chat is provided in NetPeerGroup only, so that everyone can chat with everyone.

peerChanged

public void peerChanged(net.jxta.protocol.PeerGroupAdvertisement pgAdv)
peerChanged - acts on change of peer for chat
Specified by:
peerChanged in interface PeerListener
Parameters:
PeerGroupAdvertisement - pgAdv - changed group Advt object

login

public int login(java.lang.String name,
                 boolean secured)

logout

public int logout()
logout a user
Parameters:
String - name - name used for logging

sendMessageToPeers

public int sendMessageToPeers(java.lang.String message)
sendMessageToPeers - sends message to listening peer(s).
Parameters:
String - message - to be sent

sendMessage

public int sendMessage(java.lang.String message)
Sends messages to the receiver end
Parameters:
String - message - message to be dispatched

registerUser

public net.jxta.protocol.PipeAdvertisement registerUser(java.lang.String name)
Registers a new user. Publishes its advertisement
Parameters:
String - name - user name

JXTA