social_stream-presence 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/assets/javascripts/xmpp_client.js +0 -6
- data/app/controllers/xmpp_controller.rb +17 -45
- data/app/views/xmpp/_chat.html.erb +0 -1
- data/lib/generators/social_stream/presence/templates/initializer.rb +2 -0
- data/lib/social_stream-presence.rb +1 -0
- data/lib/social_stream/migrations/presence.rb +0 -1
- data/lib/social_stream/presence/engine.rb +1 -48
- data/lib/social_stream/presence/models/buddy_manager.rb +4 -0
- data/lib/social_stream/presence/version.rb +1 -1
- data/lib/tasks/presence/synchronize.rake +36 -1
- metadata +2 -2
@@ -241,12 +241,6 @@ function initAndPlaySound(sound){
|
|
241
241
|
//Chat view jquery
|
242
242
|
////////////////////
|
243
243
|
|
244
|
-
function initDelegates(){
|
245
|
-
$('.user_presence').delegate( '.user_presence a[title]', 'hover', function(){
|
246
|
-
e.preventDefault();
|
247
|
-
});
|
248
|
-
}
|
249
|
-
|
250
244
|
function setUserFunctions(){
|
251
245
|
|
252
246
|
$("div.user_presence").click(function(event, ui){
|
@@ -52,7 +52,7 @@ class XmppController < ApplicationController
|
|
52
52
|
return
|
53
53
|
end
|
54
54
|
|
55
|
-
render :text => "
|
55
|
+
render :text => "User not connected"
|
56
56
|
end
|
57
57
|
|
58
58
|
|
@@ -117,6 +117,10 @@ class XmppController < ApplicationController
|
|
117
117
|
status = params[:status]
|
118
118
|
|
119
119
|
if setStatus(user,status)
|
120
|
+
if user && !user.connected
|
121
|
+
user.connected = true
|
122
|
+
user.save!
|
123
|
+
end
|
120
124
|
render :text => 'Status changed'
|
121
125
|
else
|
122
126
|
render :text => 'Status not changed'
|
@@ -130,7 +134,17 @@ class XmppController < ApplicationController
|
|
130
134
|
render :text => "Authorization error"
|
131
135
|
return
|
132
136
|
end
|
133
|
-
|
137
|
+
|
138
|
+
user = User.find_by_slug(params[:name])
|
139
|
+
|
140
|
+
if user && user.connected
|
141
|
+
user.connected = false
|
142
|
+
user.save!
|
143
|
+
render :text => "Ok"
|
144
|
+
return
|
145
|
+
end
|
146
|
+
|
147
|
+
render :text => "User not connected"
|
134
148
|
end
|
135
149
|
|
136
150
|
def authorization
|
@@ -158,49 +172,7 @@ class XmppController < ApplicationController
|
|
158
172
|
end
|
159
173
|
|
160
174
|
def test
|
161
|
-
puts "TEST"
|
162
|
-
|
163
|
-
# Thread.start{
|
164
|
-
|
165
|
-
# #XMPP DOMAIN
|
166
|
-
# domain = SocialStream::Presence.domain
|
167
|
-
# #PASSWORD
|
168
|
-
# password= SocialStream::Presence.password
|
169
|
-
# #SS Username
|
170
|
-
# ss_name = SocialStream::Presence.social_stream_presence_username
|
171
|
-
# ss_sid = ss_name + "@" + domain
|
172
|
-
#
|
173
|
-
# client = Jabber::Client.new(Jabber::JID.new(ss_sid))
|
174
|
-
# client.connect
|
175
|
-
# client.auth(password)
|
176
|
-
#
|
177
|
-
# #Remove all rosters
|
178
|
-
# msg = Jabber::Message::new(ss_sid, "SynchronizeRosters")
|
179
|
-
# msg.type=:chat
|
180
|
-
# client.send(msg)
|
181
|
-
#
|
182
|
-
#
|
183
|
-
# #Write rosters
|
184
|
-
# users = User.all
|
185
|
-
# checkedUsers = []
|
186
|
-
#
|
187
|
-
# users.each do |user|
|
188
|
-
# checkedUsers << user.slug
|
189
|
-
# contacts = user.contact_actors(:type=>:user)
|
190
|
-
# contacts.each do |contact|
|
191
|
-
# unless checkedUsers.include?(contact.slug)
|
192
|
-
# user_sid = user.slug + "@" + domain
|
193
|
-
# buddy_sid = contact.slug + "@" + domain
|
194
|
-
# msg = Jabber::Message::new(ss_sid, "SetRosterForBidirectionalTie&" + user_sid + "&" + buddy_sid + "&" + user.name + "&" + contact.name)
|
195
|
-
# msg.type=:chat
|
196
|
-
# client.send(msg)
|
197
|
-
# end
|
198
|
-
# end
|
199
|
-
# end
|
200
|
-
#
|
201
|
-
# client.close()
|
202
|
-
# }
|
203
|
-
|
175
|
+
#puts "TEST"
|
204
176
|
end
|
205
177
|
|
206
178
|
|
@@ -9,4 +9,6 @@ SocialStream::Presence.setup do |config|
|
|
9
9
|
config.xmpp_server_password = "G&s6GBnO)anw2Ene%K12Cb=0quj@uDmA"
|
10
10
|
#Username of the the Social Stream Admin sid
|
11
11
|
config.social_stream_presence_username = "social_stream-presence"
|
12
|
+
#True to enable Social Stream Presence
|
13
|
+
config.enable = true
|
12
14
|
end
|
@@ -1,9 +1,3 @@
|
|
1
|
-
require 'xmpp4r'
|
2
|
-
require 'xmpp4r/muc'
|
3
|
-
require 'xmpp4r/roster'
|
4
|
-
require 'xmpp4r/client'
|
5
|
-
require 'xmpp4r/message'
|
6
|
-
|
7
1
|
module SocialStream
|
8
2
|
module Presence
|
9
3
|
class Engine < Rails::Engine
|
@@ -15,48 +9,7 @@ module SocialStream
|
|
15
9
|
end
|
16
10
|
|
17
11
|
end
|
18
|
-
|
19
|
-
initializer "social_stream-presence.synchronize" do
|
20
|
-
#Synchronize User Presence
|
21
|
-
#Reset connected users when XMMP Server Down
|
22
|
-
Thread.start {
|
23
|
-
begin
|
24
|
-
#XMPP DOMAIN
|
25
|
-
domain = SocialStream::Presence.domain
|
26
|
-
#PASSWORD
|
27
|
-
password= SocialStream::Presence.password
|
28
|
-
#SS Username
|
29
|
-
ss_name = SocialStream::Presence.social_stream_presence_username
|
30
|
-
|
31
|
-
ss_sid = ss_name + "@" + domain
|
32
|
-
client = Jabber::Client.new(Jabber::JID.new(ss_sid))
|
33
|
-
client.connect
|
34
|
-
client.auth(password)
|
35
|
-
|
36
|
-
msg = Jabber::Message::new(ss_sid, "Synchronize")
|
37
|
-
msg.type=:chat
|
38
|
-
client.send(msg)
|
39
|
-
client.close()
|
40
|
-
|
41
|
-
rescue Exception => e
|
42
|
-
case e
|
43
|
-
when Errno::ECONNREFUSED
|
44
|
-
begin
|
45
|
-
users = User.find_all_by_connected(true)
|
46
|
-
users.each do |user|
|
47
|
-
user.connected = false
|
48
|
-
user.save!
|
49
|
-
end
|
50
|
-
puts "Connection to XMPP Server refused: Reset Connected Users"
|
51
|
-
rescue
|
52
|
-
end
|
53
|
-
else
|
54
|
-
puts "Unknown exception: #{e.to_s}"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
}
|
58
|
-
end
|
59
|
-
|
12
|
+
|
60
13
|
end
|
61
14
|
end
|
62
15
|
end
|
@@ -7,7 +7,42 @@ namespace :presence do
|
|
7
7
|
desc "Synchronize user presence."
|
8
8
|
task :connections => :environment do
|
9
9
|
puts "Starting presence:synchronize:connections"
|
10
|
-
|
10
|
+
|
11
|
+
begin
|
12
|
+
#XMPP DOMAIN
|
13
|
+
domain = SocialStream::Presence.domain
|
14
|
+
#PASSWORD
|
15
|
+
password= SocialStream::Presence.password
|
16
|
+
#SS Username
|
17
|
+
ss_name = SocialStream::Presence.social_stream_presence_username
|
18
|
+
|
19
|
+
ss_sid = ss_name + "@" + domain
|
20
|
+
client = Jabber::Client.new(Jabber::JID.new(ss_sid))
|
21
|
+
client.connect
|
22
|
+
client.auth(password)
|
23
|
+
|
24
|
+
msg = Jabber::Message::new(ss_sid, "Synchronize")
|
25
|
+
msg.type=:chat
|
26
|
+
client.send(msg)
|
27
|
+
client.close()
|
28
|
+
|
29
|
+
rescue Exception => e
|
30
|
+
case e
|
31
|
+
when Errno::ECONNREFUSED
|
32
|
+
desc "Reset connected users when XMMP Server Down"
|
33
|
+
puts "Connection to XMPP Server refused: Reset Connected Users"
|
34
|
+
users = User.find_all_by_connected(true)
|
35
|
+
users.each do |user|
|
36
|
+
user.connected = false
|
37
|
+
user.save!
|
38
|
+
end
|
39
|
+
else
|
40
|
+
puts "Unknown exception: #{e.to_s}"
|
41
|
+
return
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
puts "Synchronization complete"
|
11
46
|
end
|
12
47
|
|
13
48
|
desc "Remove all rosters and populate rosters from Social Stream data."
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: social_stream-presence
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Aldo Gordillo
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-10-
|
13
|
+
date: 2011-10-24 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|