$LOAD_PATH << '../' require 'yalgaar' #~ require 'lib/version' ########################################################Callbacks######################################### #Callback for Connection $connectionCallback = -> (arg0) { connectionCallback(arg0) } def connectionCallback(arg0) puts arg0 end $subscribeReturnMessageCallback = -> (arg0) { subscribeReturnMessageCallback(arg0) } def subscribeReturnMessageCallback(message) #No a presence must me json & enable puts "subscribeReturnMessageCallback@@@" puts message #TODO end $errorMsgCallback = -> (arg0) { errorMsgCallback(arg0) } def errorMsgCallback(message) puts "errorMsgCallback" puts message #TODO end $presenceMessageCallback = -> (arg0) { presenceMessageCallback(arg0) } def presenceMessageCallback(message) #must me json & enable puts "presenceMessageCallback" puts message #TODO end $historyMessageCallback = -> (arg0) { historyMessageCallback(arg0) } def historyMessageCallback(message) #No a presence must me json & enable puts "HistoryMessageCallback" puts message #TODO end $channelListCallback = -> (arg0) { channelListCallback(arg0) } def channelListCallback(message) puts "ChannelListCallback" channels=Array.new @l_iterator=0 #puts message #~ message="{\"total\":70,\"range\":[1,30],\"channels\":[\"abcd1\",\"abcd2\",\"abcd3\",\"abcd30\"]}" channelDatajson=JSON.parse(message) while channelDatajson["channels"][@l_iterator] != nil do channels[@l_iterator]=channelDatajson["channels"][@l_iterator] @l_iterator=@l_iterator+1 end puts channels #TODO end $userListCallback = -> (arg0) { userListCallback(arg0) } def userListCallback(message) puts "UserListCallback" #puts message userList=Array.new @l_iterator=0 #~ message="{\"total\":70,\"range\":[1,30],\"users\":[\"abcd1\",\"abcd2\",\"abcd3\",\"abcd30\"]}" userlistDatajson=JSON.parse(message) while userlistDatajson["users"][@l_iterator] != nil do userList[@l_iterator]=userlistDatajson["users"][@l_iterator] @l_iterator=@l_iterator+1 end puts userList #TODO end ########################################################User Area for Calling Pub-sub###################################### yalgaarClient = Yalgaar.new yalgaarClient.yalgaarConnect("ck-47046d75cf64402f",1,"123",$connectionCallback) yalgaarClient.yalgaarSubcribe("SLS",$subscribeReturnMessageCallback,$presenceMessageCallback,$errorMsgCallback) #~ yalgaarClient.yalgaarHistory("@@@@@!!!!test@@!!","100",$HistoryMessageCallback,$errorMsgCallback) loop { #~ puts "Enter for pub" #~ temp=STDIN.gets.chop #~ if temp == 5 #~ break #~ end #~ if temp !=nil yalgaarClient.yalgaarPublish("SLS","FirstTry") #~ end #puts "IN Loop" sleep 4 } ########################################################END####################################################################