Commit c520fb71 authored by Raphael's avatar Raphael

Moved socket out to separate process. Multiple thins should now be possible

parent b0c87fcf
......@@ -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'
......
......@@ -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
......@@ -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)
......@@ -242,6 +251,7 @@ DEPENDENCIES
haml
jnunemaker-validatable (= 1.8.4)!
json
magent!
mini_magick
mocha
mongo_mapper (= 0.8.4)!
......
......@@ -14,7 +14,7 @@ class SocketsController < ApplicationController
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
......@@ -4,6 +4,7 @@
class Post
require 'lib/diaspora/websocket'
require 'lib/encryptable'
include MongoMapper::Document
include ApplicationHelper
......
......@@ -8,6 +8,7 @@ development:
debug: false
socket_debug : false
socket_port: 8080
socket_collection_name: 'websocket'
pubsub_server: 'https://pubsubhubbub.appspot.com/'
test:
......
# 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 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
......@@ -44,6 +49,5 @@ module Diaspora
def unsocket_from_uid(id, opts={})
SocketsController.new.outgoing(id, Retraction.for(self), opts)
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment