annotation
@ToServer
@ToServer event Name { … }
@ToServer marks an event as a directional remote event that travels from a client up to the authority — an RPC, expressed as the ordinary event bus with a direction flag rather than a new concept. At an emit site the event's POD payload is serialized as an event id followed by its packed fields and sent through the transport seam toward the server; it does not run locally. On the far side, draining the transport (the runtime's pump) re-emits it into the normal @On dispatch, so a @Server @On(Name) handler picks it up. Use it for player intent — a move request, a fire command — that the authority must validate before it affects the world. Its mirror is @ToClients, which broadcasts the other way.
Example
program FireRequest {
property AmmoLog { shots_fired: int = 0 }
model Turret { AmmoLog }
@ToServer event Fire { direction: int = 0 } # client -> server request
@Server @On(Fire) handler HandleFire { # authority validates and applies
for (AmmoLog) in query [AmmoLog, {Turret}] {
AmmoLog.shots_fired = AmmoLog.shots_fired + direction
}
}
entry {
spawn Turret { AmmoLog { shots_fired: 0 } }
emit Fire(direction: 1) # serialized onto the wire, not run locally
}
}