Skip to content

Commit

Permalink
Moved socket out to separate process. Multiple thins should now be po…
Browse files Browse the repository at this point in the history
…ssible
  • Loading branch information
Raphael committed Sep 17, 2010
1 parent b0c87fc commit c520fb7
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 29 deletions.
5 changes: 4 additions & 1 deletion Gemfile
Expand Up @@ -28,9 +28,12 @@ gem 'redfinger', :git => 'git://github.com/rsofaer/redfinger.git'

#EventMachine
gem 'em-http-request',:git => 'git://github.com/igrigorik/em-http-request.git', :require => 'em-http'
gem 'em-websocket'
gem 'thin'

#Websocket
gem 'em-websocket'
gem 'magent', :git => 'http://github.com/dcu/magent.git'

#File uploading
gem 'carrierwave', :git => 'git://github.com/rsofaer/carrierwave.git' , :branch => 'master' #Untested mongomapper branch
gem 'mini_magick'
Expand Down
10 changes: 10 additions & 0 deletions Gemfile.lock
Expand Up @@ -47,6 +47,14 @@ GIT
bcrypt-ruby (~> 2.1.2)
warden (~> 0.10.7)

GIT
remote: http://github.com/dcu/magent.git
revision: 06513f3dac812469a55f2e365c349af4d2abc92a
specs:
magent (0.4.2)
mongo (>= 0.1.0)
uuidtools (>= 2.0.0)

GIT
remote: http://github.com/jnunemaker/mongomapper.git
revision: 931dab779011aa7acf60c1a4c7ad19e1ba838345
Expand Down Expand Up @@ -213,6 +221,7 @@ GEM
treetop (1.4.8)
polyglot (>= 0.3.1)
tzinfo (0.3.23)
uuidtools (2.1.1)
warden (0.10.7)
rack (>= 1.0.0)
webmock (1.3.5)
Expand Down Expand Up @@ -242,6 +251,7 @@ DEPENDENCIES
haml
jnunemaker-validatable (= 1.8.4)!
json
magent!
mini_magick
mocha
mongo_mapper (= 0.8.4)!
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sockets_controller.rb
Expand Up @@ -14,7 +14,7 @@ def incoming(msg)

def outgoing(uid,object,opts={})
@_request = ActionDispatch::Request.new({})
Diaspora::WebSocket.push_to_user(uid, action_hash(uid, object, opts))
Diaspora::WebSocket.queue_to_user(uid, action_hash(uid, object, opts))
end

end
1 change: 1 addition & 0 deletions app/models/post.rb
Expand Up @@ -4,6 +4,7 @@


class Post
require 'lib/diaspora/websocket'
require 'lib/encryptable'
include MongoMapper::Document
include ApplicationHelper
Expand Down
1 change: 1 addition & 0 deletions config/app_config.yml
Expand Up @@ -8,6 +8,7 @@ development:
debug: false
socket_debug : false
socket_port: 8080
socket_collection_name: 'websocket'
pubsub_server: 'https://pubsubhubbub.appspot.com/'

test:
Expand Down
26 changes: 0 additions & 26 deletions config/initializers/socket.rb

This file was deleted.

6 changes: 5 additions & 1 deletion lib/diaspora/websocket.rb
Expand Up @@ -6,6 +6,11 @@

module Diaspora
module WebSocket
def self.queue_to_user(uid, data)
channel = Magent::GenericChannel.new('websocket')
channel.enqueue({:uid => uid, :data => data})
end

def self.initialize_channels
@channels = {}
end
Expand Down Expand Up @@ -44,6 +49,5 @@ def socket_to_uid(id, opts={})
def unsocket_from_uid(id, opts={})
SocketsController.new.outgoing(id, Retraction.for(self), opts)
end

end
end

0 comments on commit c520fb7

Please sign in to comment.