|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface MSRPConference
A communication object that represents a session-mode instant messaging or chat session among multiple participants.
In addition to text messaging, this communication object can be used for transferring large files among the multiple participants.
There are two ways to create this communication object:
CommunicationSession.createMSRPConference(String)CommunicationSession.createMSRPConference(String, MSRPConversation)
During the Voice Conference, if one of the
participant tries to send a large file to the conference using MSRP protocol,
CAFE will receive the file transfer request and will trigger an event to the
CommunicationBean.
The CommunicationBean can make use of this communication object to send
the file to either all the attendees or to the selective attendees, like this:
@CommunicationBean public class MSRPConferenceBean {
@Context CommunicationSession session;
@Context CommunicationContext context;
@Context CommunicationService service;
@CommunicationEvent(type = CommunicationEvent.Type.INITIALIZATION,
communicationType = MSRPConversation.class)
void handleInit() {
MSRPConversation conv = (MSRPConversation) context.getCommunication();
String callee = conv.getParticipant().getName(); // conference uri
String caller = conv.getInitiator().getName();
// Find the voice conference.
Conference voiceConf = service.findByName(Conference.class, callee);
// Create a new msrp conference.
MSRPConference msrpConf = session.createMSRPConference(callee, conv);
// Excluding the party who sent the file transfer request, add all the
// other parties (as in this case) or add the parties selectively.
for(UserParticipant party : voiceConf.getAllParticipants()) {
if (!party.getName().equals(caller)) {
msrpConf.addParticipant(party.getName());
}
}
// thats it, the file will be transferred to the parties you just added.
}
}
In this example, the file which gets tranferred can also be stored in the
CAFE MSRP server by adding a MSRPRecorder, like this:
void handleInit() {
......
// After adding all the parties, add the MSRPRecorder to save the file locally.
MSRPRecorder recorder = sess.createParticipant(MSRPRecorder.class, "recorder");
msrpConf.addParticipant(recorder);
recorder.record("/tmp/recorded.ext");
}
Similarly, during the Voice Conference if the
attendees want to chat using session-mode instant messaging, the above bean
can be re-used without any changes. With the
MSRPRecorder, the chat history will be saved to the file.
Example #2:
From a http servlet, a large file can be sent to the conference
participants by using the MSRPPlayer, like this:
public class SimpleTestServlet extends HttpServlet{
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
... <Create MSRPConference and add the required participants>....
// After adding all the parties, send the file by adding MSRPPlayer
MSRPPlayer player = sess.createParticipant(MSRPPlayer.class, "player");
msrpConf.addParticipant(player);
player.play("/tmp/mediafile.ext");
}
}
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.glassfish.cafe.api.Communication |
|---|
Communication.State |
| Method Summary | |
|---|---|
TextMessage |
createTextMessage(String msg)
Creates the text message with the supplied text. |
| Methods inherited from interface org.glassfish.cafe.api.Communication |
|---|
addAgent, addParticipant, addParticipant, addParticipant, addParticipant, end, getAgent, getAgents, getInitiator, getName, getParticipant, getParticipant, getState, removeAgent, removeParticipant, removeParticipant, replaceParticipant |
| Method Detail |
|---|
TextMessage createTextMessage(String msg)
msg - Text data of the message
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||