use lua 5.3 in examples client

This commit is contained in:
Cloud Wu
2015-01-05 21:55:26 +08:00
parent 39cf6c99a2
commit ac85ff82a1
2 changed files with 8 additions and 10 deletions

View File

@@ -23,16 +23,14 @@ Run these in different console
```
./skynet examples/config # Launch first skynet node (Gate server) and a skynet-master (see config for standalone option)
lua examples/client.lua # Launch a client, and try to input some words.
./3rd/lua/lua examples/client.lua # Launch a client, and try to input hello.
```
## About Lua
Skynet put a modified version of lua 5.2.3 in 3rd/lua , it can share proto type between lua state (http://lua-users.org/lists/lua-l/2014-03/msg00489.html) .
Skynet now use lua 5.3.0-rc3 , http://www.lua.org/work/lua-5.3.0-rc3.tar.gz
Each lua file only load once and cache it in memory during skynet start . so if you want to reflush the cache , call skynet.cache.clear() .
You can also use the offical lua version , edit the makefile by yourself .
You can also use the other offical lua version , edit the makefile by yourself .
## How To (in Chinese)

View File

@@ -1,8 +1,11 @@
package.cpath = "luaclib/?.so"
package.path = "lualib/?.lua;examples/?.lua"
if _VERSION ~= "Lua 5.3" then
error "Use lua 5.3"
end
local socket = require "clientsocket"
local bit32 = require "bit32"
local proto = require "proto"
local sproto = require "sproto"
@@ -13,10 +16,7 @@ local fd = assert(socket.connect("127.0.0.1", 8888))
local function send_package(fd, pack)
local size = #pack
local package = string.char(bit32.extract(size,8,8)) ..
string.char(bit32.extract(size,0,8))..
pack
local package = string.pack(">s2", pack)
socket.send(fd, package)
end