-
-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41de56f
commit 456fe3d
Showing
44 changed files
with
9,189 additions
and
247 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
Yojimbo Client/Server Network Library. | ||
Copyright © 2016 - 2024, Mas Bandwidth LLC. | ||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer | ||
in the documentation and/or other materials provided with the distribution. | ||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | ||
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef YOJIMBO_H | ||
#define YOJIMBO_H | ||
|
||
#include "serialize.h" | ||
#include "yojimbo_config.h" | ||
#include "yojimbo_constants.h" | ||
#include "yojimbo_bit_array.h" | ||
#include "yojimbo_utils.h" | ||
#include "yojimbo_queue.h" | ||
#include "yojimbo_sequence_buffer.h" | ||
#include "yojimbo_address.h" | ||
#include "yojimbo_serialize.h" | ||
#include "yojimbo_message.h" | ||
#include "yojimbo_channel.h" | ||
#include "yojimbo_reliable_ordered_channel.h" | ||
#include "yojimbo_unreliable_unordered_channel.h" | ||
#include "yojimbo_connection.h" | ||
#include "yojimbo_network_simulator.h" | ||
#include "yojimbo_adapter.h" | ||
#include "yojimbo_network_info.h" | ||
#include "yojimbo_server_interface.h" | ||
#include "yojimbo_base_server.h" | ||
#include "yojimbo_server.h" | ||
#include "yojimbo_client_interface.h" | ||
#include "yojimbo_base_client.h" | ||
#include "yojimbo_client.h" | ||
|
||
/** @file */ | ||
|
||
/// The library namespace. | ||
|
||
namespace yojimbo | ||
{ | ||
using namespace serialize; | ||
} | ||
|
||
/** | ||
Initialize the yojimbo library. | ||
Call this before calling any yojimbo library functions. | ||
@returns True if the library was successfully initialized, false otherwise. | ||
*/ | ||
|
||
bool InitializeYojimbo(); | ||
|
||
/** | ||
Shutdown the yojimbo library. | ||
Call this after you finish using the library and it will run some checks for you (for example, checking for memory leaks in debug build). | ||
*/ | ||
|
||
void ShutdownYojimbo(); | ||
|
||
#endif // #ifndef YOJIMBO_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
Yojimbo Client/Server Network Library. | ||
Copyright © 2016 - 2024, Mas Bandwidth LLC. | ||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer | ||
in the documentation and/or other materials provided with the distribution. | ||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | ||
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef YOJIMBO_ADAPTOR_H | ||
#define YOJIMBO_ADAPTOR_H | ||
|
||
#include "yojimbo_config.h" | ||
|
||
namespace yojimbo | ||
{ | ||
/** | ||
Specifies the message factory and callbacks for clients and servers. | ||
An instance of this class is passed into the client and server constructors. | ||
You can share the same adapter across a client/server pair if you have local multiplayer, eg. loopback. | ||
*/ | ||
|
||
class Adapter | ||
{ | ||
public: | ||
|
||
virtual ~Adapter() {} | ||
|
||
/** | ||
Override this function to specify your own custom allocator class. | ||
@param allocator The base allocator that must be used to allocate your allocator instance. | ||
@param memory The block of memory backing your allocator. | ||
@param bytes The number of bytes of memory available to your allocator. | ||
@returns A pointer to the allocator instance you created. | ||
*/ | ||
|
||
virtual Allocator * CreateAllocator( Allocator & allocator, void * memory, size_t bytes ) | ||
{ | ||
return YOJIMBO_NEW( allocator, TLSF_Allocator, memory, bytes ); | ||
} | ||
|
||
/** | ||
You must override this method to create the message factory used by the client and server. | ||
@param allocator The allocator that must be used to create your message factory instance via YOJIMBO_NEW | ||
@returns The message factory pointer you created. | ||
*/ | ||
|
||
virtual MessageFactory * CreateMessageFactory( Allocator & allocator ) | ||
{ | ||
(void) allocator; | ||
yojimbo_assert( false ); | ||
return NULL; | ||
} | ||
|
||
/** | ||
Override this callback to process packets sent from client to server over loopback. | ||
@param clientIndex The client index in range [0,maxClients-1] | ||
@param packetData The packet data (raw) to be sent to the server. | ||
@param packetBytes The number of packet bytes in the server. | ||
@param packetSequence The sequence number of the packet. | ||
@see Client::ConnectLoopback | ||
*/ | ||
|
||
virtual void ClientSendLoopbackPacket( int clientIndex, const uint8_t * packetData, int packetBytes, uint64_t packetSequence ) | ||
{ | ||
(void) clientIndex; | ||
(void) packetData; | ||
(void) packetBytes; | ||
(void) packetSequence; | ||
yojimbo_assert( false ); | ||
} | ||
|
||
/** | ||
Override this callback to process packets sent from client to server over loopback. | ||
@param clientIndex The client index in range [0,maxClients-1] | ||
@param packetData The packet data (raw) to be sent to the server. | ||
@param packetBytes The number of packet bytes in the server. | ||
@param packetSequence The sequence number of the packet. | ||
@see Server::ConnectLoopbackClient | ||
*/ | ||
|
||
virtual void ServerSendLoopbackPacket( int clientIndex, const uint8_t * packetData, int packetBytes, uint64_t packetSequence ) | ||
{ | ||
(void) clientIndex; | ||
(void) packetData; | ||
(void) packetBytes; | ||
(void) packetSequence; | ||
yojimbo_assert( false ); | ||
} | ||
|
||
/** | ||
Override this to get a callback when a client connects on the server. | ||
*/ | ||
|
||
virtual void OnServerClientConnected( int clientIndex ) | ||
{ | ||
(void) clientIndex; | ||
} | ||
|
||
/** | ||
Override this to get a callback when a client disconnects from the server. | ||
*/ | ||
|
||
virtual void OnServerClientDisconnected( int clientIndex ) | ||
{ | ||
(void) clientIndex; | ||
} | ||
}; | ||
} | ||
|
||
#endif // #ifndef YOJIMBO_ADAPTOR_H |
Oops, something went wrong.