Jump to content




rednet- receive multiple messages


  • You cannot reply to this topic
2 replies to this topic

#1 Kouksi44

  • Members
  • 89 posts
  • LocationMunich, Germany

Posted 03 October 2014 - 03:47 PM

Maybe this question was already asked here but I didn´t find anything that helps me out.

I am trying to make some kind of network for extended rednet range just to find out if I can do it myself.

But somehow,the the client program has to connect to the server (or check if there´s a server around).

I am doing this by broadcasting a message with a specific protocol and waiting for a response of any server near me.
But when there is more then just one server my program will simply take the first to response.

How can I wait for maybe 1 second and save any response of a server I am getting during this period ?

I thought about this problem for a while now but it seems that I am too dumb to find a solution

It would be greagt if someone could help me :)

#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 03 October 2014 - 04:03 PM

Something like this?
local function getServerResponse()
  local id = os.startTimer( 1 )
  local responses = {}
  while true do
    local event = { os.pullEvent() }
    if event[ 1 ] == "rednet_message" then
      responses[ #responses + 1 ] = event
    elseif event[ 1 ] == "timer" and event[ 2 ] == id then
      return responses
    end
  end
end


#3 Kouksi44

  • Members
  • 89 posts
  • LocationMunich, Germany

Posted 03 October 2014 - 04:27 PM

This is exactly what I need thank you :)





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users