Server Side Functions#
This page covers streaming and running server side functions, which are described under Server Side Functions.
Streams#
functions-stream [functions, streams] [MUST]A stream of a function delivers the function’s value as it changes.
functions-stream-error [functions, streams] [MUST]An error from a function ends its stream with that error, and leaves other streams running.
functions-two-streams-of-one-function [functions, streams] [MUST]Each stream added for one function is a separate stream. Removing one leaves the other, and reading the removed one raises the stream error.
functions-stream-without-a-value [functions, streams] [MUST]A stream of a function with no value runs the function on each update, for its effects. Its value is the client’s null value. An error from the function ends the stream with that error.
Events#
functions-null-stream-id [functions, streams] [MUST]A null result for the call that adds a stream of a function raises the encoding error. The next call succeeds.
functions-null-event [events, functions] [MUST]A null result for the call that adds an event over a function raises the encoding error. The next call succeeds.
functions-add-event [events, functions] [MUST]An event added with
KRPC.AddEvent, over a server side function, fires.
functions-two-events-of-one-function [events, functions] [MUST]Each event added for one function is a separate event. Removing one leaves the other.
Running#
functions-compile [functions] [MUST]Compiling a function built with the expression API calls
KRPC.CompileFunctionwith it.
functions-run [functions] [MUST]Running a function passes the arguments to its parameters in order, and returns its value.
functions-argument-types [functions] [MUST]A run passes an argument of each type to its parameter, and decodes a value of each type.
NaN, the infinities, the extremes of each integer type and a null arrive intact.
functions-run-a-call [functions] [MUST]The client builds a function that makes a call with
KRPC.Expression.Call, from the same call it builds for a stream of the procedure. Running the function returns the call’s result.
functions-call-member-kinds [functions] [MUST]The client builds the call for a stream of each kind of member: a procedure, a property, a class method, a class property and a static method. A function that makes the call with
KRPC.Expression.Callreturns the member’s value.
functions-call-bound-static-method [functions, bound-classes] [MUST]The client builds the call for a static method called through its class bound to the connection. A function that makes the call returns the method’s value.
functions-call-with-a-call-argument [functions] [MUST]A function the client builds over one call computes an argument of another call. Here the instance of a class method is computed by a call that creates the object.
functions-run-without-a-value [functions] [MUST]Running a function with no value runs it once, for its effects, and returns the client’s null value.
functions-run-error [functions] [MUST]An error from a function raises that error from the run.
functions-run-argument-errors [functions] [MUST]A wrong number of arguments, an argument of the wrong type, a number out of the range of the parameter’s type, or a null for a parameter that cannot hold null, raises the argument error. This includes a collection whose items do not match the parameter’s type. The error can be the server’s
KRPC.ArgumentException, for a client that maps it to its argument error.
functions-stream-with-parameters [functions, streams] [MUST]Adding a stream for a function with parameters raises the client’s argument error.
functions-event-with-parameters [events, functions] [MUST]Adding an event for a function with parameters raises the client’s argument error.
Call Templates#
A call template names a procedure through its class or service, with no instance. It carries no arguments, so that KRPC.Expression.CallWithArguments supplies each one.
functions-call-template [functions] [MUST]A client builds a call template for each kind of member: a procedure, a property’s getter and setter, a method, a static method, and a class property’s getter and setter. A function that makes the call, with each argument computed by a function, gives the member’s value or sets it.
functions-call-template-message [functions] [MUST]A call template names the procedure, carries no arguments, and is built with no remote procedure call.
functions-call-template-default [functions] [MUST]A position that
CallWithArgumentsgives no expression for takes the parameter’s default.
functions-call-with-encoded-arguments [functions] [MUST]KRPC.Expression.CallWithArgumentsraises the argument error for a call that carries arguments, such as the call the client builds for a stream. Each argument is a function.
functions-call-template-missing-argument [functions] [MUST]Building a function over a call template fails with the argument error when a required position has no argument, the instance included.
Values#
functions-value-types [functions] [MUST]A run decodes the function’s value at its type. This holds for a floating point number, a null, a list, an empty list, a list holding a null, an object, a structure, and a list, a dictionary and a tuple that each hold a null object.
functions-stream-value-types [functions, streams] [MUST]A stream decodes the function’s value at its type, for each type a run decodes.
functions-mismatched-type [functions, function-types] [MUST]A run at a type that does not describe the function’s value raises the argument error. This holds for a tuple of another length, a set read as a list, a dictionary of another value type, an enumeration read as an integer, and a list that can hold null read as one that cannot.
functions-stream-mismatched-type [functions, function-types, streams] [MUST]Adding a stream at a type that does not describe the function’s value raises the argument error, for each mismatch a run rejects.
functions-null-for-non-nullable-type [functions] [MUST]A function whose value is null, run at a type that cannot hold null, raises the encoding error. This holds for a
doubleand for an object.
functions-stream-null-for-non-nullable-type [functions, streams] [MUST]Reading a stream of a function whose value is null, at a type that cannot hold null, raises the encoding error. This holds for a
doubleand for an object.
functions-null-in-callback [callbacks, functions, streams] [MUST]A callback on a stream of a function, at a type that cannot hold null, is not called for a null value. It is called for the values that follow. This holds for a
doubleand for an object.
Flags#
functions-flags-operations [functions] [MUST]A function combines two values of a flags enumeration it is passed, with
KRPC.Expression.Or,AndandExclusiveOr.Notgives the declared values its operand does not hold, so the difference of two values isAndof the first withNotof the second.
functions-flags-contains [functions] [MUST]A function tests whether a value of a flags enumeration holds another, as the intersection of the two equal to the value tested for.
functions-flags-stream [functions, streams] [MUST]A stream of a function that combines values of a flags enumeration follows its operands.
functions-flags-refused [functions] [MUST]Building a function that combines values of two enumerations that differ, or of an enumeration that is not a flags enumeration, raises the server’s
KRPC.InvalidOperationException.