Hello,
I need more comfort for my chatusers. In my application I use chat and notify. I works fine. The users want a sign when somebody wants to chat with them, like in skype. The minimized chatdialog is in the taskbar.
The best sign would be a growl message. The PushContext is deprecated (pushContext.push(channels.getChannel(privateUser), new FacesMessage("Hello I want to chat with you",summary)); ) .
With : eventBus.publish(CHANNEL ,
new FacesMessage(StringEscapeUtils.escapeHtml(summary),
StringEscapeUtils.escapeHtml(privateMessage)));
I reach all subscribers and not the only one to whom I want to chat.
Does anyone know a solution?
Thanks and regards from
Peter
Send a message only to one user
PrimeFaces 6.1, Extensions 6.1.1 , Mojarra 2.3 , GlassFish Server Open Source Edition 4.1 (build 13) , atmosphere-runtime 2.4.9 , Open Source ERP with Primefaces http://osretail.de/osRetail/
Hello kukeltje,
I tried your solution without success. In the chat is we use no "new FacesMessage" . My "normal" chat works fine, I have no problems with it.
regards
Peter
I tried your solution without success. In the chat is we use no "new FacesMessage" . My "normal" chat works fine, I have no problems with it.
regards
Peter
PrimeFaces 6.1, Extensions 6.1.1 , Mojarra 2.3 , GlassFish Server Open Source Edition 4.1 (build 13) , atmosphere-runtime 2.4.9 , Open Source ERP with Primefaces http://osretail.de/osRetail/
Hello Kukeltje,
here is my code for better understanding:
and the resource
The growl is in the header of the template.
You can test it. Call : http://osretail.de:8082/osRetail/ . You need a secound users it's max .. Klick in the toolbar of the first dialogue after the logon on chat and in the popup login. . Choose the user max and send a first message. You see the message. Of course all users receive the message
Thank you and regards
Peter
here is my code for better understanding:
Code: Select all
@ManagedBean
@ViewScoped
public class ChatView {
@ManagedProperty("#{logon}")
private Logon logon;
private Usr usr;
private final EventBus eventBus = EventBusFactory.getDefault().eventBus();
@ManagedProperty("de.osretail.basis.ChatUsers")
private ChatUsers users = new ChatUsers();
private String privateMessage;
private List<Usr> listeuser = null;
private String username = null;
private String user;
private int listid;
private int first;
private boolean loggedIn;
private String privateUser;
private final static String CHANNEL = "/{room}/";
private final static String CHANNELA = "/{anfrage}";
private String summary, detail;
private boolean neu = false;
public void nullsetzen() {
first=0;
}
public void sendPrivate() {
if(first==0){
first=1;
summary = "Guten Tag " +privateUser;
// only the selected user should get the message
eventBus.publish(CHANNELA ,
new FacesMessage(StringEscapeUtils.escapeHtml(summary),
StringEscapeUtils.escapeHtml(privateMessage)));
eventBus.publish(CHANNEL + username, privateUser +": "
+ StringEscapeUtils.escapeHtml(privateMessage));
}else{
eventBus.publish(CHANNEL + privateUser, username + ": "
+ StringEscapeUtils.escapeHtml(privateMessage));
eventBus.publish(CHANNEL + username, username + ": "
+ StringEscapeUtils.escapeHtml(privateMessage));
privateMessage = "";
}
}
public void login() {
RequestContext context = RequestContext.getCurrentInstance();
users.add(username);
context.execute("PF('subscriber').connect('/" + username + "')");
RequestContext.getCurrentInstance().update("form:users");
loggedIn = true;
}
public void disconnect() {
loggedIn = false;
username = null;
}
public void ini() {
usr = logon.getUsr();
user = usr.getBenutzer();
username = usr.getUsername();
username = username.replaceAll(" ", "_");
username = username.replace("Ä", "Ae").replace("Ö", "Oe").replace("Ü", "Ue").replace("ä", "ae").replace("ö", "oe").replace("ü", "ue").replace("ß", "ss");
neu = true;
}
public boolean isNeu() {
if (username == null) {
ini();
}
return neu;
}
and the resource
Code: Select all
@PushEndpoint("/{anfrage}")
@Singleton
public class AnfrageResource {
@OnMessage(encoders = {JSONEncoder.class})
public FacesMessage onMessage(FacesMessage message) {
return message;
}
}
The growl is in the header of the template.
Code: Select all
<div xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui" class="header">
<p:socket onMessage="handleMessageA" channel="/{notify}" />
<p:socket onMessage="handleMessageA" channel="/{anfrage}" />
<script>
function handleMessageA(facesmessage) {
facesmessage.severity = 'info';
PF('growl').show([ facesmessage ]);
}
</script>
<h:form id="formheader">
<p:growl widgetVar="growl" showDetail="true" life="10000"
escape="false" />
You can test it. Call : http://osretail.de:8082/osRetail/ . You need a secound users it's max .. Klick in the toolbar of the first dialogue after the logon on chat and in the popup login. . Choose the user max and send a first message. You see the message. Of course all users receive the message
Thank you and regards
Peter
PrimeFaces 6.1, Extensions 6.1.1 , Mojarra 2.3 , GlassFish Server Open Source Edition 4.1 (build 13) , atmosphere-runtime 2.4.9 , Open Source ERP with Primefaces http://osretail.de/osRetail/
I do not fully understand what you describe here, but what I think you mean is that even if you select a specific user to send a private message, everybody receives it, but I cannot realy try to reproduce in osretail (nice extensive app btw, I mentioned that earlier, but hirering a ui designer might help )magsam wrote:You can test it. Call : http://osretail.de:8082/osRetail/ . You need a secound users it's max .. Klick in the toolbar of the first dialogue after the logon on chat and in the popup login. . Choose the user max and send a first message. You see the message. Of course all users receive the message
One thing that I noticed is that I miss the endpoint for {room}/...
here ist described what I want
http://stackoverflow.com/questions/1590 ... ppoll-push
This solution no longer works. I think actually there is no solution.
http://stackoverflow.com/questions/1590 ... ppoll-push
This solution no longer works. I think actually there is no solution.
PrimeFaces 6.1, Extensions 6.1.1 , Mojarra 2.3 , GlassFish Server Open Source Edition 4.1 (build 13) , atmosphere-runtime 2.4.9 , Open Source ERP with Primefaces http://osretail.de/osRetail/
-
- Information
-
Who is online
Users browsing this forum: Google [Bot] and 43 guests