mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
use lua 5.3 in examples client
This commit is contained in:
@@ -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)
|
./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
|
## 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 other offical lua version , edit the makefile by yourself .
|
||||||
|
|
||||||
You can also use the offical lua version , edit the makefile by yourself .
|
|
||||||
|
|
||||||
## How To (in Chinese)
|
## How To (in Chinese)
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package.cpath = "luaclib/?.so"
|
package.cpath = "luaclib/?.so"
|
||||||
package.path = "lualib/?.lua;examples/?.lua"
|
package.path = "lualib/?.lua;examples/?.lua"
|
||||||
|
|
||||||
|
if _VERSION ~= "Lua 5.3" then
|
||||||
|
error "Use lua 5.3"
|
||||||
|
end
|
||||||
|
|
||||||
local socket = require "clientsocket"
|
local socket = require "clientsocket"
|
||||||
local bit32 = require "bit32"
|
|
||||||
local proto = require "proto"
|
local proto = require "proto"
|
||||||
local sproto = require "sproto"
|
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 function send_package(fd, pack)
|
||||||
local size = #pack
|
local size = #pack
|
||||||
local package = string.char(bit32.extract(size,8,8)) ..
|
local package = string.pack(">s2", pack)
|
||||||
string.char(bit32.extract(size,0,8))..
|
|
||||||
pack
|
|
||||||
|
|
||||||
socket.send(fd, package)
|
socket.send(fd, package)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user