-
Notifications
You must be signed in to change notification settings - Fork 0
/
commandhandler.rb
50 lines (47 loc) · 1.38 KB
/
commandhandler.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
class CommandHandler
def self.handle(commandArray)
cmd = commandArray[0]
if commandArray[1].class.to_s == "Array"
tid = commandArray[1].first
else
tid = commandArray[1]
end
args = commandArray[3..commandArray.length]
puts "--------------------------"
puts "COMMAND: " + cmd.inspect
puts "TRANSACTION ID: " + tid.inspect
puts "ARGUMENTS:\n" + args.inspect
puts "--------------------------"
case cmd
#these are KNOWN COMMANDS. There may be more that are unsupported.
when "connect"
["_result",tid,nil,{
"objectEncoding"=>0.0, # in most modern RTMP servers, this would be 3.0. 0.0 lets us keep AMF0 active, instead of AMF3.
# the client MUST set object encoding to AMF0, like this:
# {netconnection object}.objectEncoding = ObjectEncoding.AMF0;
"application"=>nil,
"level"=>"status",
"description"=>"Connection succeeded.",
"code"=>"NetConnection.Connect.Success"
}]
when "createStream"
["_result",tid,nil,1.0]
when "publish"
if args[1] == "record"
["onStatus",tid,nil,{
"level"=>"status",
"code"=>"Netstream.Publish.Start",
"description"=>"",
"details"=>args[0],
"clientid"=>1.0
},"onStatus",tid,nil,{
"level"=>"status",
"code"=>"Netstream.Record.Start",
"description"=>"",
"details"=>args[0],
"clientid"=>1.0
}]
end
end
end
end