Esempio n. 1
0
// NewDispatcher returns only the dispatcher
// useful on the client, where you don't need the entire RemoteRaytracer
func NewDispatcher() *gorpc.Dispatcher {
	rr := &RemoteRaytracer{
		Dispatcher: gorpc.NewDispatcher(),
	}

	rr.registerFunctions()

	return rr.Dispatcher
}
Esempio n. 2
0
func init() {
	registered = make(map[MessageID]NewSessionHandlerFunc)
	handlers = make(map[SessionID]SessionHandler)

	// Create dispatcher for session creation and other functions.
	d := gorpc.NewDispatcher()
	d.AddFunc(sendNewSession, newSession)
	d.AddFunc(sendEndSession, endSession)
	dispatcher = d

	var m MessageID
	gorpc.RegisterType(m)
	var s SessionID
	gorpc.RegisterType(s)
}
Esempio n. 3
0
// NewRemoteRaytracer initialises the remote raytracer object
func NewRemoteRaytracer(
	randomSeed int64,
	threads int, // number of threads that render simoultaneously
	maxRequestsAtOnce int, // the requests we accept at once (2*threads is a good number)
	samplesAtOnce int, // number of samples to send at once to the client
) *RemoteRaytracer {
	rr := &RemoteRaytracer{
		Samples:    samplesAtOnce,
		Raytracer:  NewConcurrentRaytracer(threads, nil, randomSeed),
		Dispatcher: gorpc.NewDispatcher(),
		Requests:   maxRequestsAtOnce,
	}

	rr.registerFunctions()

	return rr
}