node-udp-proxy
node-udp-proxy copied to clipboard
Send Message
Allow it to inject a message?
If anyone needs a solution to this issue, I found that server.handleMessage
and server.handleProxyMsg
work quite well for that, where server
is your UdpProxy
object that you created using .createServer(options);
handleMessage
allows you to send a message to the proxied server and handleProxyMsg
allows you to send a message back to the peer.
For the parameters:
-
socket
is the UDP socket you want to send the message to. There are different ways to get it but if you want to send a message to the proxied server you can either useserver.createClient
orserver.connections[server.hashD(sender)]
if you have asender
object. Both will return the socket object you need. -
proxy
is again theUdpProxy
object (probably calledserver
) -
msg
is your message buffer -
sender
is the sender of the UDP message
Hope this helps!
Check out the example in the Middleware section on the readme: https://github.com/gildean/node-udp-proxy#middleware
It allows you to intercept any message, block it completely or modify it.
Check out the example in the Middleware section on the readme: https://github.com/gildean/node-udp-proxy#middleware
It allows you to intercept any message, block it completely or modify it.
@roobscoob Was not asking how to modify or block a message but how to inject a new one
Allow it to inject a message?
My solution allows you to do just that.