Browse code

Nastavenie pritomnosti do samostatnej metody

Cinan Rakosnik authored on 24/03/2013 at 19:36:39
Showing 4 changed files
... ...
@@ -36,6 +36,9 @@ this.App =
36 36
     startPollingRoster: ->
37 37
       App.Com.fetch(event: 'app.roster.startPolling')
38 38
 
39
+    setPresence: ->
40
+      App.Com.fetch(event: 'app.roster.setPresence')
41
+
39 42
     _setupBackboneComponents: ->
40 43
       App.Collections.Contacts = new Xmpp.Collections.ContactsCollection()
41 44
 
... ...
@@ -14,4 +14,5 @@ App.Com.connect(->
14 14
   App.Com.initRoster()
15 15
   App.Com.startFetchingVcards()
16 16
   App.Com.startPollingRoster()
17
+  App.Com.setPresence()
17 18
 )
... ...
@@ -91,10 +91,16 @@ class WsRosterController < WebsocketRails::BaseController
91 91
                 send_message 'app.roster.statusChanged',
92 92
                              jid: roster_item.jid.strip.to_s, status: result
93 93
             end
94
+        end
95
+    end
94 96
 
95
-            # ak by som poslal svoju Presence, tak add_presence_callback nezachyti
96
-            # stav ludi, ktore sa odosielaju hned po zadani mojej Presence
97
-            client = connection_store[:link_roster_client][roster]
97
+    ##
98
+    # Nastav ma ako online
99
+    #
100
+    # Musi sa zavolat az po start_polling_contacts_state, inak sa nemusia
101
+    # zachytit stavy ostatnych v rosteri.
102
+    def set_presence
103
+        connection_store[:clients].each do |client|
98 104
             client.send(Jabber::Presence.new.set_type(:available))
99 105
         end
100 106
     end
... ...
@@ -52,6 +52,7 @@ WebsocketRails::EventMap.describe do
52 52
             subscribe :initRoster,          to: WsRosterController, with_method: :init_roster
53 53
             subscribe :startFetchingVcards, to: WsRosterController, with_method: :start_fetching_vcards
54 54
             subscribe :startPolling,        to: WsRosterController, with_method: :start_polling_contacts_state
55
+            subscribe :setPresence,         to: WsRosterController, with_method: :set_presence
55 56
         end
56 57
 
57 58
     end