Skip to content

Latest commit

 

History

History

udp

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

udp module


Access

gracenode.udp

Configurations

"modules": {
	"udp": {
		"servers": [
			{ name: "unique name for server", "host": "host name or IP", "port": port number }[...]
		],
		"requests": {
			"unique request name": { "host": "host name or IP", "port": port number }
		}
	}
}

#####API: startServers

void startServers(Function callback)

Starts all UDP servers and calls the callback function when all the servers are up

#####API: getServerByName

Object getServerByName(String serverName)

Returns a server object by a server name defined in the configurations

startServer MUST be called before invoking this function

Example

var server = gracenode.udp.getServerByName('server');

// handle UDP message requests
server.on('message', function (messageBuffer, requestObj) {
	// do something
});

// handle error
server.on('error', function (error) {
	// handle error
});

#####API: send

void send(String requestName, Mixed message, Object options, Function callback)

Sends a UDP packet message to destination named in the configurations

The callback returns error as the first argument and bytes sent as the second argument