Hi Jean,
You are right, the problem however is that my model object M1 is not
serializable and hence cannot be dumped by the session. In fact I
don’t want to store it even in a db since it’s a non -AR model.
Here’s my model code:
class Login
def connect id, password
@jid = id
@password = password
@cl = Jabber::Client::new(@jid)
@cl.connect(host=‘im.oracle.com’, port=5223)
@cl.auth_nonsasl(@password, false)
@cl.add_message_callback do |m|
if m.type != :error
assign_message(m.body,m.from)
if m.body == ‘exit’
@cl.close
end
end
end
end
def assign_message msg_b, msg_f
@mesage =Jabber::Message::new(msg_f,
msg_b).set_type(:normal).set_id(‘1’)
end
def throw
return @mesage.body
end
end
Now this is basically a connection object which maintains my stream
connection to a server.
Here’s the controller part.
class LoginController < ApplicationController
model :Login
def index
end
def sign_in
@jid = Jabber::JID::new(@params[‘user_name’]+‘/ruby’)
@jid.domain=‘oracle.com’
@password = params[‘pwd’]
Testing Login model creation
@log_in = Login.new
@log_in.connect(@jid,@password)
session[:sess]= @log_in
session[:sess].connect
puts(‘signed in to oracle’)
end
def throw_msg
render_text “message received : #{session[:sess].throw}”
end
end
This controller gets created everytime I send an AJAX request calling
the throw_msg method in the controller to receive the new messages
coming in the model. But since the model object cannot be persisted it
doesn’t know of the messages received.
Can you please suggest any alternative method.
~shishir
On Sep 20, 7:05 pm, Jean N. [email protected]