<p>My friend and I are re-implimenting the multiplayer server for a Warcraft 2 clone we are doing for a class project. We've only just started working on it, but I'd love to get some feedback as I'm sure w've already done plenty wrong :) </p>
<p><a href="http://github.com/aaparella/Gocraft">http://github.com/aaparella/Gocraft</a></p>
<p>Any comments would be welcome! I've been writing Go for a little while, but nothing very significant, so this is essentially my first actual project, and it is for my friend as well.</p>
<p>Thanks for your time and help! :) </p>
<hr/>**评论:**<br/><br/>lubosz: <pre><p>When this is a reimplementation, where is the first one?
Where is the client?</p></pre>Midnightblues: <pre><p>Unfortunately they're hosted privately. They're also a work in progress, as well. </p></pre>upboatact: <pre><p>some non-go naming of things (underscores in names, I'm guessing to make it look like some other language? what for?), weird comments, otherwise it's fine</p>
<p>pro tip: gometalinter will point these out</p>
<p>edit: oh, noticed that you are re-marshalling to json for every single player when broadcasting, which is sub-optimal</p></pre>Midnightblues: <pre><p>Thanks! We were just thinking that it would make some things a bit easier if we kept functions that handle messages received distinctly. </p>
<p>Thanks for the marshalling note, overlooked that by mistake.</p></pre>drwiggly: <pre><p>Your room class isn't thread/goroutine safe. The players list need to be guarded by a mutex. Probably RWMutex, take read on broadcast, take write when removing or adding. Also having Players exported probably isn't safe, should probably hide it then provide an accessor if you need it that takes the Read lock and calls a func with each item.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传