Skip to content

Callbacks

Ligustah edited this page Mar 15, 2011 · 9 revisions

onPacket(packet)

Called for each packet arriving.

global function onPacket(packet)
{
	switch(packet.packetID)
	{
		case PacketID.Login:
			writefln $ "mapSeed: {}", packet.mapSeed
			break
		case PacketID.Handshake:
			writeln $ "received handshake"
			break;
		default:
			break;
	}
}

onConnect(host, port)

Called when a connection to a server is established.

global function onConnect(host, port)
{
	writefln $ "i am connected to {}:{}", host, port
}

onDisconnect

Called when the connection is closed.

global function onDisconnect()
{
	writeln $ "damn, i got disconnected"
}
Clone this wiki locally