|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectfi.hut.tml.xsmiles.mlfc.comm.jxta.JXTACOMMImpl
This class implements a simple chat application.
It's very inspired by the hotwire application developped by Eric Pouyoul. Thanks to him for the advices and also for providing the source code of hotwire. A particular big thanks to William R. Bauer who spends time to reading the code of this application and who gives some useful advices, he spends also a lot of time trying it, thanks to him !!!
Here is how it works: First we try to find an advertisement for a chat group. If we find it, we create the pipes in order to talk with the member of the group. If we don't find it, we create a new propagate Pipe Advertisement and we publish it. It's possible that two chat groups may be on the same network. To avoid that, you must raise the sleeping time.
| Field Summary | |
static java.lang.String |
MIME_TEXT
|
| Fields inherited from interface fi.hut.tml.xsmiles.mlfc.comm.COMMInterface |
JOIN_ERROR, JOIN_GROUPCREATED, JOIN_GROUPJOINED |
| Constructor Summary | |
JXTACOMMImpl()
Main constructor. |
|
| Method Summary | |
void |
addDataListener(DataListener dl)
Receive data |
net.jxta.protocol.PipeAdvertisement |
createChatAdvertisement()
Method used to create a chat advertisement. |
void |
createInputAndOutputPipes(net.jxta.protocol.PipeAdvertisement chatAdv)
Method used to create input and output pipes from the chat advertisement. |
void |
destroy()
Do cleanup - is this enough? |
void |
discoveryEvent(net.jxta.discovery.DiscoveryEvent event)
Method used to receive new discovery event. |
boolean |
getFile(java.net.URL location,
java.lang.String name)
|
java.lang.String |
getLocalPeerName()
Get local Peer name. |
java.lang.String |
getPeerGroupName()
Get PeerGroup name. |
int |
initJXTAChat()
Method used to init the application. |
int |
join(java.lang.String name,
java.lang.String params)
This actually starts up the JXTA network and join a "group" A group is service named: "XSmiles: "+groupname |
void |
leave(java.lang.String name)
|
void |
pipeMsgEvent(net.jxta.pipe.PipeMsgEvent pipeMsgEvent)
This method is used to receive new message from the inputPipe we have created before. |
boolean |
send(java.lang.String target,
java.lang.String data)
Send data to target |
boolean |
sendFile(java.lang.String target,
java.net.URL data)
|
boolean |
sendMime(java.lang.String target,
byte[] data,
java.lang.String mimetype)
Send data to target |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String MIME_TEXT
| Constructor Detail |
public JXTACOMMImpl()
| Method Detail |
public boolean send(java.lang.String target,
java.lang.String data)
send in interface COMMInterface
public boolean sendMime(java.lang.String target,
byte[] data,
java.lang.String mimetype)
sendMime in interface COMMInterfacepublic void addDataListener(DataListener dl)
COMMInterface
addDataListener in interface COMMInterface
public boolean sendFile(java.lang.String target,
java.net.URL data)
sendFile in interface COMMInterfacetarget - Send a file to a targetdata - The URL where file is located
@return true if successful
public boolean getFile(java.net.URL location,
java.lang.String name)
getFile in interface COMMInterfacelocation - Where to save the filename - The filename to get
@return true if successfulpublic java.lang.String getLocalPeerName()
getLocalPeerName in interface COMMInterfacepublic java.lang.String getPeerGroupName()
getPeerGroupName in interface COMMInterface
public int join(java.lang.String name,
java.lang.String params)
join in interface COMMInterfaceparams - The parameters that might be neededname - The group to join
@return JOIN_ERROR, JOIN_GROUPCREATED or JOIN_GROUPJOINEDpublic void leave(java.lang.String name)
leave in interface COMMInterfacename - Leave a grouppublic void destroy()
destroy in interface COMMInterface
public int initJXTAChat()
throws java.lang.Exception
net.jxta.exception.PeerGroupException - If a peer group exception occurs.
java.lang.Exceptionpublic void discoveryEvent(net.jxta.discovery.DiscoveryEvent event)
discoveryEvent in interface net.jxta.discovery.DiscoveryListenerevent - The received event.
An - exception if something bad happenedpublic net.jxta.protocol.PipeAdvertisement createChatAdvertisement()
public void createInputAndOutputPipes(net.jxta.protocol.PipeAdvertisement chatAdv)
throws java.lang.Exception
chatAdv - The chat advertisement used to create the pipes.
java.lang.Exceptionpublic void pipeMsgEvent(net.jxta.pipe.PipeMsgEvent pipeMsgEvent)
pipeMsgEvent in interface net.jxta.pipe.PipeMsgListenerpipeMsgEvent - The pipe message event we will retrieve the message from it.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||