# README
Unity Game Server Hosting Server Library
A Golang game server can be integrated with the platform quickly by using this library. A fully-formed usage example can be found here.
Short Demonstration
A basic server can be set up by using the server.New()
function with the Start()
, Stop()
and message channels:
package main
import "github.com/Unity-Technologies/unity-gaming-services-go-sdk/game-server-hosting/server"
func main() {
s, err := server.New(server.TypeAllocation)
if err != nil {
// ...
}
// Handle server events (i.e. allocation, deallocation, errors)
done := make(chan struct{})
go handleEvents(s, done)
if err = s.Start(); err != nil {
// ...
}
if err = s.WaitUntilTerminated(); err != nil {
close(done)
// ...
}
}
func handleEvents(s *server.Server, done chan struct{}) {
for {
select {
case <-s.OnAllocate():
// handle allocation
case <-s.OnDeallocate():
// handle deallocation
case <-s.OnError():
// handle error
case <-s.OnConfigurationChanged():
// handle configuration change
case <-done:
return
}
}
}
# Functions
New creates a new instance of Server, denoting which type of server to use.
WithConfigPath sets the configuration file to use when starting the server.
WithQueryReadBuffer sets the read buffer size for the query handler.
WithQueryReadDeadlineDuration sets the read deadline duration for consuming query requests in the query handler.
WithQueryWriteBuffer sets the write buffer size for the query handler.
WithQueryWriteDeadlineDuration sets the write deadline duration for responding to query requests in the query handler.
# Constants
DefaultReadBufferSizeBytes represents the default size of the read buffer for the query handler.
DefaultReadDeadlineDuration represents the default read deadline duration for consuming a query request.
DefaultWriteBufferSizeBytes represents the default size of the write buffer for the query handler.
DefaultWriteDeadlineDuration represents the default write deadline duration for responding in the query handler.
QueryProtocolA2S represents the 'a2s' query protocol.
QueryProtocolRecommended represents the recommended query protocol.
QueryProtocolSQP represents the 'sqp' query protocol.
TypeAllocation represents a server which is using the 'allocations' model of server usage.
TypeReservation represents a server which is using the 'reservations' model of server usage.
# Variables
ErrMetricOutOfBounds represents that the metric index provided will overflow the metrics buffer.
ErrMetricsUnsupported represents that the query type this server is using does not support additional metrics.
ErrNilArgs represents that the arguments supplied are nil.
ErrNilContext represents that the context supplied is nil.
ErrNotAllocated represents that the server is not allocated.
ErrOperationNotApplicable represents that the operation being performed is not applicable to the server type.
ErrUnsupportedQueryType is an error that specifies the provided query type is not supported by this library.
# Type aliases
No description provided by the author
No description provided by the author
No description provided by the author