-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rb
71 lines (54 loc) · 1.31 KB
/
main.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
require 'rubygems'
require 'sinatra'
require 'soap/rpc/driver'
require 'erb'
require 'sass'
enable :sessions
NAMESPACE = 'ChatRoom'
URL = 'http://localhost:8080/axis/services/ChatRoom.jws?wsdl'
driver = SOAP::RPC::Driver.new(URL, NAMESPACE)
driver.add_method('getUsersOnline')
driver.add_method('sendMessage', 'id_sender', 'id_receiver', 'message')
driver.add_method('getFirstMessages', 'id', 'id_sender')
driver.add_method('login', 'id')
driver.add_method('logout', 'id')
get '/' do
redirect '/chat' unless session[:chat_id].nil?
erb :index
end
get '/send_message/:id' do
driver.sendMessage(session[:chat_id], params[:id], params[:message].split('%20').join(' '))
""
end
get '/message/:id' do
driver.getFirstMessages(session[:chat_id], params[:id])
end
post '/chat' do
session[:chat_id] = params[:id]
@id = session[:chat_id]
driver.login(@id)
erb :chat
end
get '/chat' do
@id = session[:chat_id]
driver.login(@id)
erb :chat
end
get '/chat_avec/:id' do
@id = session[:chat_id]
@client = params[:id]
erb :chat_avec
end
get '/logout' do
driver.logout(session[:chat_id])
session[:chat_id] = nil
redirect '/'
end
get '/utilisateurs_en_ligne' do
@clients = driver.getUsersOnline.split(':').reverse
@clients.pop
erb :utilisateurs_en_ligne
end
get '/style.css' do
sass :style
end