Openpoker source code analysis

Source: Internet
Author: User

Reprinted: http://hpyhacking.iteye.com/blog/1166481

Recently, I have been focusing on Erlang programming. Erlang has a linguistic talent in processing network concurrency, which can help me solve many problems on the game server, presumably everyone who has been in touch with Erlang has read "a large-scale multiplayer online system that easily achieves scalability, fault tolerance, and load balancing". After reading this, there will always be an impulse to be eager to try ~
This article is a long time ago, but the design described in it is still very practical. The combination of Erlang and game is a good reference, from basic learning of Erlang to source code learning.

 

This isSeries of articles, I will record what I have learned from openpoker for further in-depth and reference ~

 

For more information about the openpoker project, see the article above. However, the article was a long time ago and the author quietly updated the project, some of the concepts mentioned in this article are missing in the new Code. After reading this article, it will become a reference. Let's look at this series a little bit ~

 

This project has been updated by the author on GitHub, but the author has changed the open-source protocol to no commercial use. Click here to find the latest source code of the project ~

 

Source code Overview

 

First, let's take a look at the directory structure of the project, which is a standard Erlang project. The doc directory contains protocol instructions and installation instructions. The src directory stores all the source code, the first thing we need to do is first look at all the source code ~

 

Simply look at the source code name to know the server. erl this file is not simple, it is very important, and to understand this project exch. erl and game. erl and G. the combination of ERL files is also the key point of understanding.

 

Start the server

 

The author put the emakefile In the src directory, which is uncomfortable. He put the file in the project root directory and overwritten the file.

 

 

Erlang code
  1. {'Src/limit ', [debug_info, {outdir, "Ebin"}]}.
  2. {'Src/exch', [debug_info, {outdir, "Ebin"}]}.
  3. {'Src/* ', [debug_info, {outdir, "Ebin"}]}.

 

 

This is the Erlang make file, which will be compiled based on the source file date. First, we need to understand why the limit and Exch modules are compiled first, because these are two self-defined OTP modules implemented by the author, it can be understood as the interface in the OO language. These two modules will be used for subsequent compilation.

 

The project can be compiled smoothly without executing the following names in the project root directory. Some unused Methods warnning appear, which are reserved by the author for server control. ignore this.

 

 

Bash code
  1. $> Erl-make

 

 

The server starts to run after compilation. After compilation is successful, you must switch the directory to the Ebin directory.

 

 

Bash code
  1. $> Erl-sname Test

 

 

Initialize the database table according to the instructions in DOC/install, and then start the server.

 

 

Erlang code
  1. Erl> Schema: Install ().
  2. Erl> server: Start ("127.0.0.1", 8002)

 

 

Now the server of a poker game is running, and the client can communicate with port 8002.

 

The first article will come here first, and I will discuss more about the source code ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.