You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I set the "to_client" parameter, the client will receive two duplicate messages.
Why is it designed like this?
// HandleMessages send messages to a specific connected clientfunc (e*Websocket) HandleMessages() {
validate:= utils.Validator{}
for {
// Grab the next message from the broadcast channelmsg:=<-e.Broadcast// Send to Clientifmsg.IsValid() &&!validate.IsEmpty(msg.ToClient) &&!validate.IsEmpty(msg.Channel) &&validate.IsUUID4(msg.ToClient) {
// Push message to that client if it still connected// or remove from clients if we can't deliver messages to// it anymoreifclient, ok:=e.Clients.Get(msg.ToClient); ok {
// --------------------------------------------First--------------------------------------------------err:=client.(*websocket.Conn).WriteJSON(msg)
iferr!=nil {
client.(*websocket.Conn).Close()
e.Clients.Delete(msg.ToClient)
}
}
}
// Send to client Peers on a channelifmsg.IsValid() &&!validate.IsEmpty(msg.FromClient) &&!validate.IsEmpty(msg.Channel) &&validate.IsUUID4(msg.FromClient) {
channel:= api.Channel{}
channel.Init()
iter:=channel.ChannelScan(msg.Channel).Iterator()
foriter.Next() {
ifmsg.FromClient==iter.Val() {
continue
}
msg.ToClient=iter.Val()
ifmsg.ToClient!=""&&validate.IsUUID4(msg.ToClient) {
ifclient, ok:=e.Clients.Get(msg.ToClient); ok {
// --------------------------------------------Second--------------------------------------------------err:=client.(*websocket.Conn).WriteJSON(msg)
iferr!=nil {
client.(*websocket.Conn).Close()
e.Clients.Delete(msg.ToClient)
}
}
}
}
}
}
}
The text was updated successfully, but these errors were encountered:
That must be a bug then, will check while working on v2 & backport to master
Regarding your question
Public channels should be used for publicly accessible data as they do not require any form authorisation in order to be subscribed to.
Private channels should be used when access to the channel needs to be restricted in some way.
Presence channels build on the security of private channels and expose the additional feature of an awareness of who is subscribed to that channel. It can be used to add "who's online" type of functionality to your application
When I set the "to_client" parameter, the client will receive two duplicate messages.
Why is it designed like this?
The text was updated successfully, but these errors were encountered: