Skip to content
rolevax edited this page Mar 12, 2017 · 1 revision

Pancake Mahjong Server Documentation for Contributors

Programming Languages

  • Go: network related logics
  • C++: wrap the libsaki library

C++ is wrapped by SWIG.

Database Schema

See the database schema page for details.

Go Package Structure

There are some sub-packages in the main bitbucket.org/rolevax/sakilogy-server package

  • srv server logics
  • saki wrapped libsaki library

The srv Package

Long-live objects:

  • sing singletons
  • sing.UssnMgr user session (connection) manager
  • sing.TssnMgr table session manager
  • sing.BookMgr book manager
  • sing.Dao DB access object
  • sing.Rao Redis access object

Most long-live objects have Loop() methods. Loop() selects from incoming channels. Methods named as handleXxx runs in same goroutine as Loop(), and exported methods should run in different goroutines.

Ad-hoc objects:

  • ussn: user session
  • tssn: table session

Most ad-hoc objects have a loopXxx or xxx.Loop() function/method. Ad-hoc objects should always be allocated inside the loopXxx(). The naming convention (handleXxx() vs Exported()) is same as long-live objects.

Explanations about some dangerous code

  • BookType: 0, 1, 2, 3 for 应援、替补、正选、ACE respectively.
  • Number "2" of "choose one girl out of two" is hard coded everywhere. search around and refactor when it is needs to be changed to 3.