padeir0 / gna Goto Github PK
View Code? Open in Web Editor NEWgame networking abstraction.
License: The Unlicense
game networking abstraction.
License: The Unlicense
https://github.com/kazhmir/gna/blob/7c6ca39c05dc1666adbea025b151731860cb3d52/group.go#L52
This creates an exponential relationship between number of players in the server and number of encodings. When #players > 100, the gob.Encode function takes most of the execution time, while encoding the same object, limiting the maximum number of players to ~365 in my machine.
If the Group encodes and send the raw bytes to each dispatcher it should cut it. Although i'm not sure how to do it without the gob complaining.
Something on the lines of:
func (g *Group) ship(dt interface{}) {
g.mu.Lock()
defer g.mu.Unlock()
var b bytes.Buffer
enc := gob.NewEncoder(&b)
err := enc.Encode(&dt)
if err != nil {
return
}
bff := b.Bytes()
raw := make([]byte, len(bff))
copy(raw, bff)
for _, p := range g.pMap {
p.shipRaw(raw)
}
}
But this is kind of ugly and makes gob spit out "duplicate type received".
Reusing the encoder and buffer makes the gob complain: "corrupted data" and "unknown type".
I may try a MultiWriter, but i'm not sure how the write errors are going to be handled this way.
I will need to dig through the gob internals and try out some options.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.