Only broadcast to authenticated clients.
This commit is contained in:
parent
3b47de0014
commit
08c2a59569
1 changed files with 60 additions and 56 deletions
|
@ -19,7 +19,7 @@ module Sessions
|
|||
|
||||
start new session
|
||||
|
||||
Sessions.create( client_id, session_data, { :type => 'websocket' } )
|
||||
Sessions.create( client_id, session_data, { type: 'websocket' } )
|
||||
|
||||
returns
|
||||
|
||||
|
@ -124,21 +124,21 @@ returns
|
|||
|
||||
{
|
||||
'4711' => {
|
||||
:user => {
|
||||
user: {
|
||||
'id' => 123,
|
||||
},
|
||||
:meta => {
|
||||
:type => 'websocket',
|
||||
:last_ping => time_of_last_ping,
|
||||
meta: {
|
||||
type: 'websocket',
|
||||
last_ping: time_of_last_ping,
|
||||
}
|
||||
},
|
||||
'4712' => {
|
||||
:user => {
|
||||
user: {
|
||||
'id' => 124,
|
||||
},
|
||||
:meta => {
|
||||
:type => 'ajax',
|
||||
:last_ping => time_of_last_ping,
|
||||
meta: {
|
||||
type: 'ajax',
|
||||
last_ping: time_of_last_ping,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
@ -230,12 +230,12 @@ get session data
|
|||
returns
|
||||
|
||||
{
|
||||
:user => {
|
||||
user: {
|
||||
'id' => 123,
|
||||
},
|
||||
:meta => {
|
||||
:type => 'websocket',
|
||||
:last_ping => time_of_last_ping,
|
||||
meta: {
|
||||
type: 'websocket',
|
||||
last_ping: time_of_last_ping,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -345,7 +345,7 @@ returns
|
|||
|
||||
=begin
|
||||
|
||||
send message to all client
|
||||
send message to all authenticated client
|
||||
|
||||
Sessions.broadcast(data)
|
||||
|
||||
|
@ -360,6 +360,10 @@ returns
|
|||
# list all current clients
|
||||
client_list = sessions
|
||||
client_list.each {|client_id|
|
||||
session = Sessions.get(client_id)
|
||||
next if !session
|
||||
next if !session[:user]
|
||||
next if !session[:user]['id']
|
||||
Sessions.send(client_id, data)
|
||||
}
|
||||
true
|
||||
|
|
Loading…
Reference in a new issue