Skip to content
FutureBlitz

    Install

    Import std.net.game.peer

    std.net.game.peer

    std.net.game's peers: the other side of a connection, as a GameHost has it. A peer sends its messages on its channels, which go at the host's next Update, and keeps what the connection knows: its state, the round-trip time it measures from acks, and the packets it's sent, received, and lost. Every packet acks the 33 latest of the other side's it received, and a reliable part not acked once its round-trip time and a margin have passed goes again, each time waiting twice as long, up to 8 times. A Flush sends 16 packets at most, and a peer that takes 16 acks them at once, so the acks of a packet lost cover what was before it.

    std/net/game/peer.fb

    Types

    PeerState enum

    Public Enum PeerState

    Where a connection is.

    std/net/game/peer.fb, line 18

    • CONNECTING enum member #

      Asking for it.

    • CONNECTED enum member #

      Open.

    • DISCONNECTING enum member #

      Sending what's left before it ends.

    • DISCONNECTED enum member #

      Ended.

    GamePeer class

    Public Class GamePeer Implements Printable

    The other side of a connection, which a GameHost makes when it connects or is connected to. Its Send queues a message on one of the host's channels, which goes at the host's next Update, along with what it sends again and its acks.

    std/net/game/peer.fb, line 63

    • Public Property Address: SocketAddress property #

      Where the other side is.

    • Public Property State: PeerState property #

      Whether it's connecting, connected, or disconnected, and how.

    • Public Property Reason: DisconnectReason property #

      Why it disconnected, once it has, or NONE.

    • Public Property RoundTripTime: Duration property #

      The round-trip time, smoothed as TCP smooths it, from the acks of what it sent, and how much it varies. Before the first ack, 100 and 50 milliseconds.

    • Public Property RoundTripVariance: Duration property #

      How much its round-trip time varies.

    • Public Property PacketLoss: Double property #

      About how much of what it sends is lost, from 0 to 1: of its packets acked or counted lost, the recent ones counting most.

    • Public Property PacketsSent: Int64 property #

      The packets it's sent, received, and counted lost, the reliable parts it sent again, and the bytes of its packets each way.

    • Public Property PacketsReceived: Int64 property #

      How many packets it's received.

    • Public Property PacketsLost: Int64 property #

      How many of its packets it's counted lost.

    • Public Property Resends: Int64 property #

      How many reliable parts it's sent again.

    • Public Property BytesSent: Int64 property #

      How many bytes of packets it's sent.

    • Public Property BytesReceived: Int64 property #

      How many bytes of packets it's received.

    • Public Property Unacked: Int property #

      How many reliable messages it has that the other side hasn't acked yet, sent or not.

    • @PanicsAtCaller Public Method Send(channel: Int, bytes: UInt8[]) method #

      Sends bytes on the host's channel, from 0, as the channel's kind says; it goes at the host's next Update, once it's connected. A peer that's disconnecting or disconnected sends nothing more. Panics for a channel the host doesn't have, or a message past its MaxMessageSize.

    • @PanicsAtCaller Public Method Send(channel: Int, text: String) method #

      Sends text's UTF-8 on the host's channel.

    • Public Method Disconnect() method #

      Ends the connection once the other side has acked every reliable message sent so far, or at the host's Timeout: the host's Update then tells the other side, and gives a DISCONNECT event of LOCAL. A peer that's still connecting stops at once.

    • Public Method DisconnectNow() method #

      Ends the connection at the host's next Update, dropping what hasn't gone.

    • Public Method ToString(): String method #

      Its address, as "127.0.0.1:5000".

    Report an issue with this page or with FutureBlitz on GitHub.