@@ -157,20 +157,31 @@ public void onMessage(Session userSession, String message) {
157157 }else if (channelId .equals ("<auto>" )){
158158 //get active channel
159159 if (user != null ){
160- channelId = user .getActiveChannel ();
161- channelAccepted = true ;
162- //check this channel here or assume that all "active channels" really exist and the user is allowed to use it?
160+ //do we have a user that can be in any channel? Then get the receiver active channel
161+ if (user .isOmnipresent ()){
162+ SocketUser rec = SocketUserPool .getActiveUserById (msg .receiver );
163+ if (rec != null ){
164+ channelId = rec .getActiveChannel (); //TODO: does it sense to broadcast this to all users with this ID not only active?
165+ msg .channelId = channelId ; //refresh
166+ channelAccepted = true ;
167+ }
168+ }else {
169+ channelId = user .getActiveChannel (); //Note: I wonder what happens when the user is the assistant that is active in all channels?
170+ msg .channelId = channelId ; //refresh
171+ //check this channel here or assume that all "active channels" really exist and the user is allowed to use it?
172+ channelAccepted = true ;
173+ }
163174 }
164175 }else {
165176 //validate channel - TODO: this procedure has potential to fail when channel operations are not in sync with user, I'm sure, I think, maybe ... ^^
166177 //user must exists if a message should be sent to channel
167178 if (user != null ){
168- sc = SocketChannelPool .getChannel (channelId );
179+ SocketChannel testSc = SocketChannelPool .getChannel (channelId );
169180 //channel exists?
170- if (sc != null ){
181+ if (testSc != null ){
171182 //user is active in this channel?
172183 if (!user .getActiveChannel ().equals (channelId )){
173- if (sc .isUserMemberOfChannel (user )){
184+ if (testSc .isUserMemberOfChannel (user )){
174185 //user.setActiveChannel(channelId); //do this here?
175186 channelAccepted = true ;
176187 }
@@ -203,7 +214,8 @@ public void onMessage(Session userSession, String message) {
203214 //simply broadcast
204215 if (dataType == null
205216 || dataType .equals (DataType .openText .name ())
206- || dataType .equals (DataType .assistAnswer .name ())
217+ || dataType .equals (DataType .assistAnswer .name ())
218+ || dataType .equals (DataType .assistFollowUp .name ())
207219 || dataType .equals (DataType .directCmd .name ())
208220 ){
209221 preBroadcastAction (user , msg , false , false , false );
@@ -522,7 +534,7 @@ public void broadcastMessage(SocketMessage msg){
522534 //Sends message to all active users of a certain channel - message assumes channelId was checked before
523535 @ Override
524536 public void broadcastMessage (SocketMessage msg , String channelId ){
525- //TODO: check channel "<auto>"
537+ //TODO: check channel "<auto>" again? - should have been replaced in channel-check at start ...
526538 SocketChannel sc = SocketChannelPool .getChannel (channelId );
527539 List <SocketUser > activeChannelUsers = sc .getActiveMembers (false ); //TODO: this one is tricky, for normal messages it should be "false"
528540 broadcastMessage (msg , activeChannelUsers );
0 commit comments