SightedClient

class SightedClient[F[_], SelfBoundPackets <: Tuple, PeerBoundPackets <: Tuple, WorldView](val transport: ProtocolBasedTransport[F, SelfBoundPackets, PeerBoundPackets], val identity: ClientIdentity, viewRef: Ref[F, WorldView], abstraction: TransportPacketAbstraction[Union[SelfBoundPackets], WorldView, F[List[Response]]])(implicit evidence$1: Spawn[F])

The class of Minecraft clients that associate incoming packets to updates of state of the connected world. The name "Sighted" is from an analogy between the animals receiving light rays to their eyes and Minecraft clients receiving client-bound packets - they both shape the assumptions (view) about the external environment using those incoming data.

These clients make a distinction between hidden "internal" packets and "visible" packets within SelfBoundPackets. Internal packets are packets that are abstracted away by abstraction, and cannot be observed by users of this class; they contribute to the automatic update of the clients' view of the world. Visible packets are those that are not filtered by the abstraction.

Value Params
abstraction

the object abstracting packets from transport.

identity

the identity of this client

transport

INTERNAL, the transport that this client uses. Users should use nextPacketOrViewUpdate or writePacket wherever possible.

viewRef

reference to a WorldView that this client keeps updating

Companion
object
class Object
trait Matchable
class Any

Value members

Concrete methods

def writePacket[P : CanEncode](packet: P): F[Unit]

Write a packet to the underlying transport.

Write a packet to the underlying transport.

Concrete fields

val keepReadingPackets: Resource[F, Unit]

The resource of process that keeps reading packets from the transport, discarding the result. Acquiring this resource has an effect of letting packets go through the abstraction, meaning that auto-responses by abstractions will be made while this resource is being held.

The resource of process that keeps reading packets from the transport, discarding the result. Acquiring this resource has an effect of letting packets go through the abstraction, meaning that auto-responses by abstractions will be made while this resource is being held.

When this resource goes out of scope, the packet-reading process is cancelled.

val nextPacket: F[Union[SelfBoundPackets]]

Keep reading packets from the transport, until we see a visible packet, and return. By definition, the returned Tuple.Union[SelfBoundPackets] will not contain packets abstracted away by the abstraction.

Keep reading packets from the transport, until we see a visible packet, and return. By definition, the returned Tuple.Union[SelfBoundPackets] will not contain packets abstracted away by the abstraction.

val nextPacketOrViewUpdate: F[Option[Union[SelfBoundPackets]]]

Read the next packet, either internal or visible, and return the result.

Read the next packet, either internal or visible, and return the result.

If we have read an internal packet, the client's view of the world is updated by the abstraction function, then a None is returned. Otherwise the client's view will remain unchanged and the read visible packet will be returned in a Some.

As a consequence, the returned Tuple.Union[SelfBoundPackets] will not contain packets abstracted away by the abstraction.

This action is cancellable (when the client is waiting for next packet) and is atomic.

val transport: ProtocolBasedTransport[F, SelfBoundPackets, PeerBoundPackets]
val worldView: F[WorldView]

Read the current view of the world as seen from this client.

Read the current view of the world as seen from this client.