$LOAD_PATH << '../' require 'yalgaar' ########################################################Callbacks######################################### #Callback for Connection $connectionCallback = -> (arg0) { connectionCallback(arg0) } def connectionCallback(arg0) puts arg0 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 $errorMsgCallback = -> (arg0) { errorMsgCallback(arg0) } def errorMsgCallback(message) puts "errorMsgCallback" puts message #TODO end ########################################################User Area for Calling Pub-sub###################################### yalgaarClient = Yalgaar.new #yalgaarConnect(clientKey,isSecure,$connectionCallback)# yalgaarClient.yalgaarConnect("ck-47046d75cf64402f",1,$connectionCallback) sleep 2 #yalgaarGetChannelList(UUID,$ChannelListCallback,$errorMsgCallback)# yalgaarClient.yalgaarGetChannelList("123",$ChannelListCallback,$errorMsgCallback) #yalgaarGetUserList(Channel,$UserListCallback,$errorMsgCallback)# yalgaarClient.yalgaarGetUserList("SLS",$UserListCallback,$errorMsgCallback) ########################################################END####################################################################