Moved socket out to separate process. Multiple thins should now be possible
This commit is contained in:
parent
b0c87fcffa
commit
c520fb71a7
7 changed files with 22 additions and 29 deletions
5
Gemfile
5
Gemfile
|
|
@ -28,9 +28,12 @@ gem 'redfinger', :git => 'git://github.com/rsofaer/redfinger.git'
|
||||||
|
|
||||||
#EventMachine
|
#EventMachine
|
||||||
gem 'em-http-request',:git => 'git://github.com/igrigorik/em-http-request.git', :require => 'em-http'
|
gem 'em-http-request',:git => 'git://github.com/igrigorik/em-http-request.git', :require => 'em-http'
|
||||||
gem 'em-websocket'
|
|
||||||
gem 'thin'
|
gem 'thin'
|
||||||
|
|
||||||
|
#Websocket
|
||||||
|
gem 'em-websocket'
|
||||||
|
gem 'magent', :git => 'http://github.com/dcu/magent.git'
|
||||||
|
|
||||||
#File uploading
|
#File uploading
|
||||||
gem 'carrierwave', :git => 'git://github.com/rsofaer/carrierwave.git' , :branch => 'master' #Untested mongomapper branch
|
gem 'carrierwave', :git => 'git://github.com/rsofaer/carrierwave.git' , :branch => 'master' #Untested mongomapper branch
|
||||||
gem 'mini_magick'
|
gem 'mini_magick'
|
||||||
|
|
|
||||||
10
Gemfile.lock
10
Gemfile.lock
|
|
@ -47,6 +47,14 @@ GIT
|
||||||
bcrypt-ruby (~> 2.1.2)
|
bcrypt-ruby (~> 2.1.2)
|
||||||
warden (~> 0.10.7)
|
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
|
GIT
|
||||||
remote: http://github.com/jnunemaker/mongomapper.git
|
remote: http://github.com/jnunemaker/mongomapper.git
|
||||||
revision: 931dab779011aa7acf60c1a4c7ad19e1ba838345
|
revision: 931dab779011aa7acf60c1a4c7ad19e1ba838345
|
||||||
|
|
@ -213,6 +221,7 @@ GEM
|
||||||
treetop (1.4.8)
|
treetop (1.4.8)
|
||||||
polyglot (>= 0.3.1)
|
polyglot (>= 0.3.1)
|
||||||
tzinfo (0.3.23)
|
tzinfo (0.3.23)
|
||||||
|
uuidtools (2.1.1)
|
||||||
warden (0.10.7)
|
warden (0.10.7)
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
webmock (1.3.5)
|
webmock (1.3.5)
|
||||||
|
|
@ -242,6 +251,7 @@ DEPENDENCIES
|
||||||
haml
|
haml
|
||||||
jnunemaker-validatable (= 1.8.4)!
|
jnunemaker-validatable (= 1.8.4)!
|
||||||
json
|
json
|
||||||
|
magent!
|
||||||
mini_magick
|
mini_magick
|
||||||
mocha
|
mocha
|
||||||
mongo_mapper (= 0.8.4)!
|
mongo_mapper (= 0.8.4)!
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class SocketsController < ApplicationController
|
||||||
|
|
||||||
def outgoing(uid,object,opts={})
|
def outgoing(uid,object,opts={})
|
||||||
@_request = ActionDispatch::Request.new({})
|
@_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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
|
|
||||||
class Post
|
class Post
|
||||||
|
require 'lib/diaspora/websocket'
|
||||||
require 'lib/encryptable'
|
require 'lib/encryptable'
|
||||||
include MongoMapper::Document
|
include MongoMapper::Document
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ development:
|
||||||
debug: false
|
debug: false
|
||||||
socket_debug : false
|
socket_debug : false
|
||||||
socket_port: 8080
|
socket_port: 8080
|
||||||
|
socket_collection_name: 'websocket'
|
||||||
pubsub_server: 'https://pubsubhubbub.appspot.com/'
|
pubsub_server: 'https://pubsubhubbub.appspot.com/'
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
# Copyright (c) 2010, Diaspora Inc. This file is
|
|
||||||
# licensed under the Affero General Public License version 3. See
|
|
||||||
# the COPYRIGHT file.
|
|
||||||
|
|
||||||
|
|
||||||
require 'em-websocket'
|
|
||||||
require 'eventmachine'
|
|
||||||
require 'lib/diaspora/websocket'
|
|
||||||
EM.next_tick {
|
|
||||||
Diaspora::WebSocket.initialize_channels
|
|
||||||
|
|
||||||
EventMachine::WebSocket.start(
|
|
||||||
:host => "0.0.0.0",
|
|
||||||
:port => APP_CONFIG[:socket_port],
|
|
||||||
:debug =>APP_CONFIG[:socket_debug]) do |ws|
|
|
||||||
ws.onopen {
|
|
||||||
|
|
||||||
sid = Diaspora::WebSocket.subscribe(ws.request['Path'].gsub('/',''), ws)
|
|
||||||
|
|
||||||
ws.onmessage { |msg| SocketsController.new.incoming(msg) }
|
|
||||||
|
|
||||||
ws.onclose { Diaspora::WebSocket.unsubscribe(ws.request['Path'].gsub('/',''), sid) }
|
|
||||||
}
|
|
||||||
end
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -6,6 +6,11 @@
|
||||||
|
|
||||||
module Diaspora
|
module Diaspora
|
||||||
module WebSocket
|
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
|
def self.initialize_channels
|
||||||
@channels = {}
|
@channels = {}
|
||||||
end
|
end
|
||||||
|
|
@ -44,6 +49,5 @@ module Diaspora
|
||||||
def unsocket_from_uid(id, opts={})
|
def unsocket_from_uid(id, opts={})
|
||||||
SocketsController.new.outgoing(id, Retraction.for(self), opts)
|
SocketsController.new.outgoing(id, Retraction.for(self), opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue