... | ... |
@@ -8,6 +8,7 @@ this.App = |
8 | 8 |
Com: |
9 | 9 |
connect: -> |
10 | 10 |
App._dispatcher = new WebSocketRails('localhost:3000/websocket') |
11 |
+ App._dispatcher.trigger('app.roster.connect') |
|
11 | 12 |
|
12 | 13 |
fetch: (options) -> |
13 | 14 |
App._dispatcher.trigger(options.event, options.data, options.success, options.error) |
... | ... |
@@ -1,16 +1,21 @@ |
1 | 1 |
class RosterController < WebsocketRails::BaseController |
2 |
+ include Jabber |
|
2 | 3 |
|
3 | 4 |
def initialize_session |
4 | 5 |
controller_store[:friends] = {} |
5 | 6 |
end |
6 | 7 |
|
8 |
+ def connect |
|
9 |
+ hack_sessions() |
|
10 |
+ |
|
11 |
+ login() |
|
12 |
+ get_roster() |
|
13 |
+ end |
|
14 |
+ |
|
7 | 15 |
## |
8 | 16 |
# Vrat vsetkych priatelov v rosteri |
9 |
- def get |
|
10 |
- #logger.debug request. |
|
11 |
- #controller_store[:friends] |
|
12 |
- |
|
13 |
- trigger_success message: "yes" |
|
17 |
+ def get_roster |
|
18 |
+ controller_store[:friends] |
|
14 | 19 |
end |
15 | 20 |
|
16 | 21 |
## |
... | ... |
@@ -18,4 +23,11 @@ class RosterController < WebsocketRails::BaseController |
18 | 18 |
def add_friend(data) |
19 | 19 |
|
20 | 20 |
end |
21 |
+ |
|
22 |
+ private |
|
23 |
+ |
|
24 |
+ def hack_sessions |
|
25 |
+ session[:a] = true |
|
26 |
+ session.delete :a |
|
27 |
+ end |
|
21 | 28 |
end |
... | ... |
@@ -45,7 +45,8 @@ WebsocketRails::EventMap.describe do |
45 | 45 |
namespace :app do |
46 | 46 |
|
47 | 47 |
namespace :roster do |
48 |
- subscribe :read, :to => RosterController, :with_method => :get |
|
48 |
+ subscribe :connect, to: RosterController, with_method: :connect |
|
49 |
+ subscribe :read, to: RosterController, with_method: :get |
|
49 | 50 |
end |
50 | 51 |
|
51 | 52 |
end |