You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: yojimbo.h
+57-17Lines changed: 57 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -604,7 +604,7 @@ namespace yojimbo
604
604
};
605
605
606
606
/**
607
-
Allocator implementation based on malloc and free.
607
+
The default allocator implementation based around malloc and free.
608
608
*/
609
609
610
610
classDefaultAllocator : publicAllocator
@@ -646,7 +646,7 @@ namespace yojimbo
646
646
};
647
647
648
648
/**
649
-
Allocator built on the TLSF allocator implementation by Matt Conte. Thanks Matt!
649
+
An allocator built on the TLSF allocator implementation by Matt Conte. Thanks Matt!
650
650
This is a fast allocator that supports multiple heaps. It's used inside the yojimbo server to silo allocations for each client to their own heap.
651
651
See https://github.com/mattconte/tlsf for details on this allocator implementation.
652
652
*/
@@ -3437,16 +3437,25 @@ namespace yojimbo
3437
3437
3438
3438
/**
3439
3439
A reference counted object that can be serialized to a bitstream.
3440
+
3440
3441
Messages are objects that are sent between client and server across the connection. They are carried inside the ConnectionPacket generated by the Connection class. Messages can be sent reliable-ordered, or unreliable-unordered, depending on the configuration of the channel they are sent over.
3442
+
3441
3443
To use messages, create your own set of message classes by inheriting from this class (or from BlockMessage, if you want to attach data blocks to your message), then setup an enum of all your message types and derive a message factory class to create your message instances by type.
3444
+
3442
3445
There are macros to help make defining your message factory painless:
3446
+
3443
3447
YOJIMBO_MESSAGE_FACTORY_START
3444
3448
YOJIMBO_DECLARE_MESSAGE_TYPE
3445
3449
YOJIMBO_MESSAGE_FACTORY_FINISH
3450
+
3446
3451
Once you have a message factory, register it with your declared inside your client and server classes using:
3452
+
3447
3453
YOJIMBO_MESSAGE_FACTORY
3454
+
3448
3455
which overrides the Client::CreateMessageFactory and Server::CreateMessageFactory methods so the client and server classes use your message factory type.
3456
+
3449
3457
See tests/shared.h for an example showing you how to do this, and the functional tests inside tests/test.cpp for examples showing how how to send and receive messages.
3458
+
3450
3459
@see BlockMessage
3451
3460
@see MessageFactory
3452
3461
@see Connection
@@ -3589,10 +3598,6 @@ namespace yojimbo
3589
3598
3590
3599
/**
3591
3600
A message which can have a block of data attached to it.
3592
-
Attaching blocks of data is very useful, especially over a reliable-ordered channel where these blocks can be larger that the maximum packet size. Blocks sent over a reliable-ordered channel are automatically split up into fragments and reassembled on the other side.
3593
-
This gives you have the convenience of a reliable-ordered control messages, while attaching large blocks of data (larger than max packet size), while having all messages delivered reliably and in-order.
3594
-
Situations where this can be useful is when sending down the initial state of the world on client connect, or block of configuration data to send up from the client to server on connect.
3595
-
It can also be used for messages sent across an unreliable-unordered channel, but in that case blocks aren't split up into fragments. Make sure you consider this when designing your channel budgets when sending blocks over unreliable-unordered channels.
3596
3601
@see ChannelConfig
3597
3602
*/
3598
3603
@@ -3728,10 +3733,13 @@ namespace yojimbo
3728
3733
3729
3734
/**
3730
3735
Defines the set of message types that can be created.
3736
+
3731
3737
You can derive a message factory yourself to create your own message types, or you can use these helper macros to do it for you:
3738
+
3732
3739
YOJIMBO_MESSAGE_FACTORY_START
3733
3740
YOJIMBO_DECLARE_MESSAGE_TYPE
3734
3741
YOJIMBO_MESSAGE_FACTORY_FINISH
3742
+
3735
3743
See tests/shared.h for an example showing how to use the macros.
3736
3744
*/
3737
3745
@@ -4614,7 +4622,7 @@ namespace yojimbo
4614
4622
};
4615
4623
4616
4624
/**
4617
-
Connection class.
4625
+
Sends and receives messages across a set of user defined channels.
4618
4626
*/
4619
4627
4620
4628
classConnection
@@ -4818,9 +4826,9 @@ namespace yojimbo
4818
4826
};
4819
4827
4820
4828
/**
4821
-
Adapter class
4822
-
This is used to integrate your game engine with yojimbo.
4823
-
It lets you specify the message factory to be used by client and server, as well as to implement various callbacks.
4829
+
Specifies the message factory and callbacks for clients and servers.
4830
+
An instance of this class is passed into the client and server constructors.
4831
+
You can share the same adapter across a client/server pair if you have local multiplayer, eg. loopback.
4824
4832
*/
4825
4833
4826
4834
classAdapter
@@ -4829,20 +4837,42 @@ namespace yojimbo
4829
4837
4830
4838
virtual~Adapter() {}
4831
4839
4832
-
// todo: document this class
4840
+
/**
4841
+
Override this function to specify your own custom allocator class.
4842
+
@param allocator The base allocator that must be used to allocate your allocator instance.
4843
+
@param memory The block of memory backing your allocator.
4844
+
@param bytes The number of bytes of memory available to your allocator.
4845
+
@returns A pointer to the allocator instance you created.
0 commit comments