Module Proxy.Service_handler

Handlers for services (objects added via the registry).

class type ['a, 'v, 'role] t = object ... end

An ('a, 'v, 'role) t handles incoming messages for a service object of type 'a.

val attach_proxy : ('a, [ `Unknown ], 'role) proxy -> ['a, [> `V1 ] as 'v, 'role] t -> ('a, 'v, 'role) proxy

attach_proxy p t sets t as the handler for p.

Any method argument that corresponds to a new object will arrive as a half-initialsed proxy (created by the generated bindings using accept_new). This function must be called immediately (before switching threads or using the proxy) so that any future events addressed to this object can be handled.

val attach : ('a, [ `Unknown ], 'role) proxy -> ['a, [> `V1 ], 'role] t -> unit

Like attach_proxy, but ignores the resulting proxy. Useful if the object only needs to respond to messages from the peer, but otherwise doesn't do anything.

val interface : [_, _, _] t -> string

interface t is the interface from t's metadata.

val min_version : [_, _, _] t -> int32

min_version t is the minimum version supported by t.

val cast_version : ('a, _, 'role) t -> ('a, _, 'role) t

If the version rules turn out to be too restrictive, this can be used to disable them. Using this incorrectly may lead to a protocol error (such as receiving an event for which no handler was registered).

Functions for use by generated code

val accept_new : (_, 'v, [< `Client | `Server ] as 'role) proxy -> int32 -> (module Metadata.S with type t = 'a) -> version:int32 -> ('a, [ `Unknown ], 'role) proxy

accept_new parent id metadata ~version registers a new object, with an ID allocated by the peer.

The generated bindings call this when receiving a new object, before passsing the resulting half-initialised proxy to the application code.