BlitzMax

BlitzMax

  • Downloads
  • Docs
  • API
  • Resources
  • About

›BRL

BlitzMax API

  • Introduction

BRL

    Audio

    • Introduction
    • TChannel
    • TSound

    AudioSample

    • Introduction
    • TAudioSample
    • TAudioSampleLoader

    Bank

    • Introduction
    • TBank

    BankStream

    • Introduction
    • TBankStream

    Base64

    • Introduction
    • TBase64

    Blitz

    • Introduction
    • TArrayBoundsException
    • TBlitzException
    • TNullFunctionException
    • TNullMethodException
    • TNullObjectException
    • TOutOfDataException
    • TRuntimeException
  • BRL.BMPLoader
  • Clipboard

    • Introduction
    • TClipboard
    • TClipboardOpts
    • TWin32ClipboardOpts
    • TX11ClipboardOpts
  • BRL.D3D7Max2D
  • BRL.D3D9Max2D
  • BRL.DirectSoundAudio
  • BRL.EndianStream
  • Event

    • Introduction
    • TEvent
  • BRL.EventQueue
  • BRL.FileSystem
  • BRL.FreeAudioAudio
  • BRL.GLGraphics
  • BRL.GLMax2D
  • BRL.GNet
  • BRL.Graphics
  • BRL.Hook
  • BRL.JPGLoader
  • BRL.KeyCodes
  • LinkedList

    • Introduction
    • TList
    • TListEnum
    • TLink

    Map

    • Introduction
    • TMap
    • TIntMap
    • TIntKey
    • TPtrMap
    • TPtrKey
    • TStringMap
  • BRL.Math
  • Matrix

    • Introduction
    • SMat2D
    • SMat2F
    • SMat2I
    • SMat3D
    • SMat3F
    • SMat3I
    • SMat4D
    • SMat4F
    • SMat4I

    Max2D

    • Introduction
    • TImage

    MaxLua

    • Introduction
    • TLuaClass
    • TLuaObject
  • BRL.OGGLoader
  • BRL.OpenALAudio
  • ObjectList

    • Introduction
    • TObjectList
    • TObjectListEnumerator
    • TObjectListReverseEnumerator

    Pixmap

    • Introduction
    • TPixmap
    • TPixmapLoader
  • BRL.PNGLoader
  • BRL.PolledInput
  • Quaternion

    • Introduction
    • SQuatD
    • SQuatF
    • SQuatI
  • BRL.RamStream
  • Random

    • Introduction
    • TRandom

    Reflection

    • Introduction
    • TTypeId
    • TMember
    • TConstant
    • TField
    • TGlobal
    • TFunction
    • TMethod
  • BRL.Retro
  • BRL.Socket
  • BRL.SocketStream
  • BRL.StandardIO
  • Stream

    • Introduction
    • TCStream
    • TIO
    • TStream
    • TStreamException
    • TStreamFactory
    • TStreamReadException
    • TStreamWrapper
    • TStreamWriteException

    StringBuilder

    • Introduction
    • TStringBuilder
    • TSplitBuffer
  • BRL.System
  • BRL.SystemDefault
  • BRL.TextStream
  • BRL.TGALoader
  • ThreadPool

    • Introduction
    • TRunnable
    • TThreadPoolExecutor

    Threads

    • Introduction
    • TThread
    • TThreadData
    • TMutex
    • TSemaphore
    • TCondVar

    Timer

    • Introduction
    • TChrono
  • BRL.TimerDefault
  • Vector

    • Introduction
    • SVec2D
    • SVec2F
    • SVec2I
    • SVec3D
    • SVec3F
    • SVec3I

    Volumes

    • Introduction
    • TVolume
  • BRL.WAVLoader

Text

    Format

    • Introduction
    • TFormatter

    JConv

    • Introduction
    • TJConv
    • TJConvBuilder
    • TJConvSerializer

    Json

    • Introduction
    • TJSON
    • TJSONObject
    • TJSONString
    • TJSONInteger
    • TJSONReal
    • TJSONBool
    • TJSONArray
    • TJSONNull
    • TJSONError
    • TJSONNumber

    Regex

    • Introduction
    • TRegEx
    • TRegExMatch
    • TRegExOptions
    • TRegExException

    Xml

    • Introduction
    • TxmlDoc
    • TxmlNode
    • TxmlAttribute

MaxGUI

  • MaxGUI.MaxGUI
  • MaxGUI.Drivers
  • MaxGUI.Localization
  • MaxGUI.ProxyGadgets
  • MaxGUI.CocoaMaxGUI
  • MaxGUI.Win32MaxGUIEx

PUB

  • Pub.FreeJoy
  • Pub.FreeProcess
  • Pub.Glad
  • Pub.Glew
  • Joystick

    • Introduction
    • TJoystickDriver
  • Pub.Lua
  • Pub.OpenAL
  • Pub.OpenGLES
  • Pub.xmmintrin
  • Pub.ZLib

Crypto

    Digest

    • Introduction
    • TMessageDigest
    • TDigestRegister
    • TNoSuchAlgorithmException

    Cipher

    • Introduction
    • TCipher
    • TCipherMode
    • Crypto.AESCipher
    • Crypto.AnubisCipher
    • Crypto.BlowfishCipher
    • Crypto.CamelliaCipher
    • Crypto.Cast5Cipher
    • Crypto.DESCipher
    • Crypto.IdeaCipher
    • Crypto.KasumiCipher
    • Crypto.KhazadCipher
    • Crypto.KSeedCipher
    • Crypto.NoekeonCipher
    • Crypto.SerpentCipher
    • Crypto.SkipjackCipher
    • Crypto.TwofishCipher
    • Crypto.XTeaCipher

    CBCMode

    • Introduction
    • TCBCCipherMode

    CFBMode

    • Introduction
    • TCFBCipherMode

    CTRMode

    • Introduction
    • TCTRCipherMode

    ECBMode

    • Introduction
    • TECBCipherMode

    F8Mode

    • Introduction
    • TF8CipherMode

    LRWMode

    • Introduction
    • TLRWCipherMode

    OFBMode

    • Introduction
    • TOFBCipherMode

    XTSMode

    • Introduction
    • TXTSCipherMode

    Blake2BDigest

    • Introduction
    • TBlake2B_512
    • TBlake2B_384
    • TBlake2B_256
    • TBlake2B_160

    CRC32

    • Introduction
    • TCRC32

    MD5Digest

    • Introduction
    • TMD5

    Ripemd320Digest

    • Introduction
    • TRipemd320

    Ripemd356Digest

    • Introduction
    • TRipemd256

    Ripemd160Digest

    • Introduction
    • TRipemd160

    Ripemd128Digest

    • Introduction
    • TRipemd128

    SHA1Digest

    • Introduction
    • TSHA1

    SHA256Digest

    • Introduction
    • TSHA256

    SHA512Digest

    • Introduction
    • TSHA512

    SHA3Digest

    • Introduction
    • TSHA3_512
    • TSHA3_384
    • TSHA3_256
    • TSHA3_224

    TigerDigest

    • Introduction
    • TTiger

    WhirlpoolDigest

    • Introduction
    • TWhirlpool

    Crypto

    • Introduction
    • TCryptoRandom
    • TCryptoSecretBox
    • TCryptoHash
    • TCryptoSign
    • TCryptoKeyExchange
    • TCryptoKey
    • TCryptoHashKey
    • TCryptoSecretBoxKey
    • TCryptoSignature
    • TCryptoExchangeKeyPair
    • TCryptoSessionKeyPair
    • TCryptoNPacket
    • TCryptoKK1Packet
    • TCryptoKK2Packet
    • TCryptoXX1Packet
    • TCryptoXX2Packet
    • TCryptoXX3Packet
    • TCryptoExchangeState
    • TCryptoPWHashMasterKey
    • TCryptoPWHashStoredKey
    • TCryptoPasswordHash

SDL

    SDL

    • Introduction
    • TSDLStream

    SDLSystem

    • Introduction
    • TSDLMultiGesture

    SDLVideo

    • Introduction
    • TSDLDisplay
    • TSDLDisplayMode
    • TSDLGLContext
    • TSDLWindow

    SDLRender

    • Introduction
    • TSDLRenderer
    • TSDLTexture

    SDLTimer

    • Introduction
    • TSDLTimer

    SDLHaptic

    • Introduction
    • TSDLHaptic
    • TSDLHapticCondition
    • TSDLHapticConstant
    • TSDLHapticCustom
    • TSDLHapticDirection
    • TSDLHapticEffect
    • TSDLHapticLeftRight
    • TSDLHapticPeriodic
    • TSDLHapticRamp

    SDLSensor

    • Introduction
    • TSDLSensor
  • SDL.SDLFreeAudio
  • SDL.GLSDLMax2D
  • SDL.GL2SDLMax2D
  • SDL.D3D9SDLMax2D
  • SDLVirtualJoystick

    • Introduction
    • TVirtualJoystick

Steam

    SteamSDK

    • Introduction
    • TSteamClient
    • TSteamUtils
    • TSteamUserStats
    • TSteamFriends
    • TSteamUGC
    • ISteamFriendsListener
    • ISteamUGCListener
    • ISteamUserStatsListener
    • ISteamUtilsListener
    • EItemPreviewType
    • EPersonaChange
    • EPersonaState
    • ERemoteStoragePublishedFileVisibility
    • EUGCMatchingUGCType
    • EUGCQuery
    • EUserRestriction
    • EUserUGCList
    • EWorkshopFileType
Edit

BRL.GNet

The GameNet module (GNet for short) provides a set of commands for creating and managing multiplayer network games.

GNet works a little differently than other networking libraries. Instead of being primarily 'message based', GNet works by synchronizing a collection of GNet objects over a network.

Each GNet object contains 32 &slots which are similar in nature to the fields of BlitzMax objects. You can write to these slots using the SetGNetInt, SetGNetFloat and SetGNetString commands, and read from these slots using the GetGNetInt, GetGNetFloat and GetGNetString commands. The actual meaning of the data contained in these slots is completely up to you, but will typically include such information as player position, score, hitpoints and so on.

Note that you can only modify GNet objects that you have yourself created. Such objects are known as local objects, while objects created elsewhere are known as remote objects.

To start using GNet, you must first create a GNet host with the CreateGNetHost command. Once you have created a host, you can either connect to other GNet hosts using GNetConnect, or prepare to accept connections from other hosts using GNetListen.

The GNetSync command brings all GNet objects up to date. This involves notifying other hosts about any modifications you have made to local GNet objects, and processing notifications from other hosts about any modifications to remote GNet objects.

Following a GNetSync, you can check which objects have been modified, created or closed using the GnetObjects command. This returns a linked list of GNet objects in a particular state.

GNet also provides a simple messaging system. A GNet message is actually just a special type of GNet object, so you initialize messages using the standard GNet commands for writing slots. Once created and initialized, a message can be sent to a remote object using the SendGNetMessage command.

Incoming messages can be processed using the GNetMessages command after a GNetSync. This function returns a linked list of messages objects which can be examined using the standard GNet commands for reading slots. In addition, the GNetMessageObject command can be used to determine which local object a message was intended for.

Functions

Function CreateGNetHost:TGNetHost()

Create GNet host

Once you have created a GNet host, you can use it to create objects with CreateGNetObject, connect to other hosts with GNetConnect and listen for connections from other hosts with GNetListen.

Returns

A new GNet host


Function CloseGNetHost( host:TGNetHost )

Close a GNet host

Once closed, a GNet host cannot be reopened.


Function GNetSync( host:TGNetHost )

Synchronize GNet host

GNetSync will update the state of all GNet objects. Once you have used this command, use the GNetObjects function to determine which objects have been remotely created, modified or closed.


Function GNetListen:Int( host:TGNetHost,port:Int )

Listen for connections

Causes host to start listening for connection attempts on the specified port. Once a host is listening, hosts on other machines can connect using GNetConnect.

GNetListen may fail if port is already in use by another application, or if host is already listening or has already connected to a remote host using GNetConnect.

Returns

True if successful, otherwise false


Function GNetConnect:Int( host:TGNetHost,address$,port:Int,timeout_ms:Int=10000 )

Connect to a remote GNet host

Attempts to connect host to the specified remote address and port.

A GNet host must be listening (see GNetListen) at the specified address and port for the connection to succeed.

Returns

True if connection successful, otherwise false


Function GNetObjects:TList( host:TGNetHost,state:Int=GNET_ALL )

Get a list of GNet objects

GNetObjects returns a list of GNet objects in a certain state.

The state parameter controls which objects are listed, and can be one of &GNET_ALL, &GNET_CREATED, &GNET_MODIFIED or &GNET_CLOSED.

Note that with the exception of &GNET_ALL, the returned lists will only ever contain remote objects.

Returns

A linked list


Function GNetMessages:TList( host:TGNetHost )

Get a list of GNet messages sent to local objects

Returns

A linked list


Function CreateGNetObject:TGNetObject( host:TGNetHost )

Create a GNet object

Returns

A new GNet object


Function CreateGNetMessage:TGNetObject( host:TGNetHost )

Create a GNet message object

Returns

A new GNet object


Function SendGNetMessage( msg:TGNetObject,toObject:TGNetObject )

Send a GNet message to a remote object


Function GNetMessageObject:TGNetObject( msg:TGNetObject )

Get message target object

Returns

The object that msg was sent to


Function GNetObjectState:Int( obj:TGNetObject )

Get state of a GNet object

The returned value can be one of the following:

Object StateMeaning
GNET_CREATEDObject has been created
GNET_SYNCEDObject is in sync
GNET_MODIFIEDObject has been modified
GNET_CLOSEDObject has been closed
GNET_ZOMBIEObject is a zombie
GNET_MESSAGEObject is a message object
Zombie objects are objects that have been successfully closed and will never again be used by GameNet. Therefore, such objects will never appear in any list returned by the [GNetObjects](../../brl/brl.gnet/#function-gnetobjectstlist-hosttgnethoststateintgnetall-) function.

Returns

An integer state


Function GNetObjectLocal:Int( obj:TGNetObject )

Determine whether a GNet object is local

Returns

True if object is a local object


Function GNetObjectRemote:Int( obj:TGNetObject )

Determine whether a GNet object is remote

Returns

True if object is a remote object


Function SetGNetInt( obj:TGNetObject,index:Int,value:Int )

Set GNet object int data


Function SetGNetFloat( obj:TGNetObject,index:Int,value# )

Set GNet object float data


Function SetGNetFloat( obj:TGNetObject,index:Int,value:Double )

Set GNet object float data

There may be a precision loss during the conversion of Double to Float.


Function SetGNetString( obj:TGNetObject,index:Int,value$ )

Set GNet object string data


Function GetGNetInt:Int( obj:TGNetObject,index:Int )

Get GNet object int data


Function GetGNetFloat#( obj:TGNetObject,index:Int )

Get GNet object float data


Function GetGNetString$( obj:TGNetObject,index:Int )

Get GNet object string data


Function SetGNetTarget( obj:TGNetObject,target:Object )

Set a GNet object's target object

This command allows you to bind an abitrary object to a GNet object.


Function GetGNetTarget:Object( obj:TGNetObject )

Get a GNet object's target object

Returns

The currently bound target object


Function CloseGNetObject( obj:TGNetObject )

Close a GNet object


← BRL.GLMax2DBRL.Graphics →
  • Functions
    • Function CreateGNetHost:TGNetHost()
    • Function CloseGNetHost( host:TGNetHost )
    • Function GNetSync( host:TGNetHost )
    • Function GNetListen:Int( host:TGNetHost,port:Int )
    • Function GNetConnect:Int( host:TGNetHost,address$,port:Int,timeout_ms:Int=10000 )
    • Function GNetObjects:TList( host:TGNetHost,state:Int=GNET_ALL )
    • Function GNetMessages:TList( host:TGNetHost )
    • Function CreateGNetObject:TGNetObject( host:TGNetHost )
    • Function CreateGNetMessage:TGNetObject( host:TGNetHost )
    • Function SendGNetMessage( msg:TGNetObject,toObject:TGNetObject )
    • Function GNetMessageObject:TGNetObject( msg:TGNetObject )
    • Function GNetObjectState:Int( obj:TGNetObject )
    • Function GNetObjectLocal:Int( obj:TGNetObject )
    • Function GNetObjectRemote:Int( obj:TGNetObject )
    • Function SetGNetInt( obj:TGNetObject,index:Int,value:Int )
    • Function SetGNetFloat( obj:TGNetObject,index:Int,value# )
    • Function SetGNetFloat( obj:TGNetObject,index:Int,value:Double )
    • Function SetGNetString( obj:TGNetObject,index:Int,value$ )
    • Function GetGNetInt:Int( obj:TGNetObject,index:Int )
    • Function GetGNetFloat#( obj:TGNetObject,index:Int )
    • Function GetGNetString$( obj:TGNetObject,index:Int )
    • Function SetGNetTarget( obj:TGNetObject,target:Object )
    • Function GetGNetTarget:Object( obj:TGNetObject )
    • Function CloseGNetObject( obj:TGNetObject )
BlitzMax
Docs
Getting StartedDownloadsAbout
Community
ResourcesSyntaxBomb Forums
More
GitHubStarChat on Discord
Copyright © 2022 Bruce A Henderson