Sorry, accidentally broke the links. The code for the dispatcher is here: https://github.com/kazhmir/gna/blob/master/dispatcher.go#L81 And the issue is here: https://github.com/kazhmir/gna/issues/1
Em quarta-feira, 23 de dezembro de 2020 às 19:45:10 UTC-2, meera escreveu: > I am trying to create a package for game servers using gob. The current > approach is an application level multicasting over TCP, having a gob > encoder and decoder for each player connection, and set up a goroutine to > receive and another to dispatch for each one. The code for the dispatcher > is here. But summarized, it simply receives data from a channel and encodes > it. > > The problem is that if i want to transmit a single piece of data to all > players, this piece of data is encoded again and again for each connection, > doing duplicate work. With less than 100 players this is not a problem, but > with 300+ my machine is at almost 100% usage and the profiler shows that > most of it is spent on encoding. Here's the issue on github. > > I tryied using a io.MultiWriter but gob complains of duplicate type > received, and if i try to write the raw bytes from the gob.Encoder i get > corrupted data. An option is using UDP Broadcasting but since gob expects a > stream, i'm affraid i will run into unexpected behavior when packets start > to be lost and fragmented. > > Does gob expect a single encoder and decoder to own the stream? Not > allowing two encoders on the server for one decoder on the client? > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/b369690c-c3e5-4516-848e-72ce4cf7fb5cn%40googlegroups.com.