was me saying, basically, the rest of the function code - i just didnt want to copy it all out - seemed a bit pointless-- more code
LUBE (Networking Library)
Re: LUBE (Networking Library)
i havent over ridden them....
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: LUBE (Networking Library)
So the connection callback triggers, but the receive ones never do? Have you tried sending from the client to the server? Do you update the client too?
Re: LUBE (Networking Library)
client calls update(dt) yeah.
and yeah the callbacks are getting called
the recieves get called because they are getting constantly called in the update :
its just this, in the client, always returns : nil, timed out, nil
here is some of the client receive logic
so the first function receive() never gets called
but in the client:update()
if self.callbacks.recv then
local data, err = self:_receive()
this does get called
and yeah the callbacks are getting called
the recieves get called because they are getting constantly called in the update :
Code: Select all
function udpClient:_receive()
local data, ip, port = self.socket:receivefrom()
here is some of the client receive logic
so the first function receive() never gets called
but in the client:update()
if self.callbacks.recv then
local data, err = self:_receive()
this does get called
Code: Select all
function client:receive()
-- Check if we're connected and pass it on.
print("client receive")
if not self.connected then
return false, "Not connected"
end
return self:_receive()
end
function client:update(dt)
if not self.connected then return end
assert(dt, "Update needs a dt!")
-- First, let's handle ping messages.
if self.ping then
self.ping.timer = self.ping.timer + dt
if self.ping.timer > self.ping.time then
self:_send(self.ping.msg)
self.ping.timer = 0
end
end
-- If a recv callback is set, let's grab
-- all incoming messages. If not, leave
-- them in the queue.
if self.callbacks.recv then
local data, err = self:_receive()
while data do
self.callbacks.recv(data)
data, err = self:_receive()
end
end
end
Re: LUBE (Networking Library)
Hi
thought id post back with an example of the server recieving from the client :
server code :
client code :
in LUBE
so because data always returns "nil", it never calls my self.callbacks.recv() function
i am really baffled...
thought id post back with an example of the server recieving from the client :
server code :
Code: Select all
function onConnect(id)
server:send("hi", id) -- never gets through
print(id) -- always prints id
end
function onReceive(data, id)
print(data .. "sent from "..id) -- always see this
end
function StartServer()
server = lube.udpServer()
server:listen("7000")
server.callbacks.connect = onConnect
server.callbacks.recv = onReceive
server.handshake = "Hi!"
print("started server")
end
Code: Select all
_ip = "127.0.0.1"
_port = "7000"
function StartClient()
client = lube.udpClient()
client.handshake = "Hi!"
client.callbacks.recv = Receive
success, er = client:connect(_ip, _port)
print("success : " .. tostring(success)) -- always true, even if the server hasnt been started
client:send("hello") -- server always receives and prints this (see above)
return success
end
Code: Select all
function client:update(dt)
if not self.connected then return end
assert(dt, "Update needs a dt!")
-- First, let's handle ping messages.
if self.ping then
self.ping.timer = self.ping.timer + dt
if self.ping.timer > self.ping.time then
self:_send(self.ping.msg)
self.ping.timer = 0
end
end
-- If a recv callback is set, let's grab
-- all incoming messages. If not, leave
-- them in the queue.
if self.callbacks.recv then
local data, err = self:_receive()
print(data) -- always nil/false
print(err) -- "Unknown remote sent data." (from the function udpClient:_receive()
while data do
self.callbacks.recv(data)
data, err = self:_receive()
end
end
end
i am really baffled...
Re: LUBE (Networking Library)
Is there a way to stop the server? I searched through the source, but I couldn't find anything.
Re: LUBE (Networking Library)
A library that requires another unincluded library, and class-based at that? Meh, I prefer the old version, but I'm picky. Terrific library!
"Bump." -CMFIend420
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: LUBE (Networking Library)
It does come with a fallback class library, but if a class commons-compatible library is present, it will use that instead.
Re: LUBE (Networking Library)
why classes in lua? lua's strong side is the way of not using object oriented (in my view at least).
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: LUBE (Networking Library)
Because lua is amazing because it allows you to do whatever you want.jjmafiae wrote:why classes in lua? lua's strong side is the way of not using object oriented (in my view at least).
With that out of the way, I am using a slightly class-based design for lube these days, but it's mostly because in my opinion objects fit this api well. Don't forget that lua's files mostly act like objects too. And love is object-oriented too!
Re: LUBE (Networking Library)
I have trouble getting the client recieve packets from server.
Client to Server = success
Server to Client = fail
my server code: http://hastebin.com/dakiguhegu.lua
my client code: http://hastebin.com/caquvofequ.lua
EDIT got it working with tcp connection but udp still fails on server sending data to user
Client to Server = success
Server to Client = fail
my server code: http://hastebin.com/dakiguhegu.lua
my client code: http://hastebin.com/caquvofequ.lua
EDIT got it working with tcp connection but udp still fails on server sending data to user
Who is online
Users browsing this forum: No registered users and 4 guests