---
# System prepended metadata

title: Untitled

---

## Server
Chạy memcached:
![](https://i.imgur.com/6df5Vv5.png)

Config:
![](https://i.imgur.com/62EFeMd.png)

Tải SDK 1.8 (không xài bản cao hơn).

Config SDK:
![](https://i.imgur.com/ENVJ4cD.png)

Sửa module setting -- `8`:
![](https://i.imgur.com/9LGQvEM.png)

Run ngon lành:
![](https://i.imgur.com/RTZ4taA.png)


## Client

Sửa: res/ipConfig.json
```
{"server":"127.0.0.1","port":1101}
```

Khi chạy sẽ ra được cái này
![](https://i.imgur.com/uTqjiYK.png)

Trong src/cmd/send/demo/ResponseRequestUserInfo.java phía server, ta sẽ thấy:
```java
package cmd.send.demo;

import bitzero.server.extensions.data.BaseMsg;

import cmd.CmdDefine;

import java.nio.ByteBuffer;

import model.PlayerInfo;

public class ResponseRequestUserInfo extends BaseMsg {
    public PlayerInfo info;
    public ResponseRequestUserInfo(PlayerInfo _info) {
        super(CmdDefine.GET_USER_INFO);
        info = _info;
    }
    
    @Override
    public byte[] createData() {
        ByteBuffer bf = makeBuffer();
        bf.putInt(info.position.x);
        bf.putInt(info.position.y);
        return packBuffer(bf);
    }
}
```

Nó gửi 2 Int.

Trong src/modules/testnetwork/network/Packet.js phía client, ta sẽ thấy:
```java
testnetwork.packetMap[gv.CMD.USER_INFO] = fr.InPacket.extend(
    {
        ctor:function()
        {
            this._super();
        },
        readData:function(){
            this.token = this.getInt();
            this.name = this.getString();
            this.x = this.getInt();
            this.y = this.getInt();
        }
    }
);
```

Nó nhận 1 Int rồi 1 String mới tới 2 Int.. vậy bỏ 2 dòng đầu đi.
Done.
![](https://i.imgur.com/EvNMc7e.png)


//{"server":"120.138.65.108","port":10088}    