merona 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/frame/config/config_connection.rb +1 -0
- data/frame/config/config_db.rb +3 -0
- data/frame/config/config_server.rb +1 -0
- data/frame/config/config_sharedmem.rb +4 -0
- data/frame/main.rb +26 -0
- data/frame/merona.rb +17 -0
- data/tests/test_chat.rb +23 -0
- data/tests/test_connect.rb +42 -0
- data/tests/test_sqlite.rb +29 -0
- data/tests/test_util.rb +6 -0
- metadata +11 -1
@@ -0,0 +1 @@
|
|
1
|
+
CONNECTION_NODELAY = 1
|
@@ -0,0 +1 @@
|
|
1
|
+
SERVER_WORKERS = 5
|
data/frame/main.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Merona main
|
2
|
+
|
3
|
+
import 'merona'
|
4
|
+
import 'config/*'
|
5
|
+
|
6
|
+
begin
|
7
|
+
if meInitialize
|
8
|
+
Log.output "Merona engine started"
|
9
|
+
else
|
10
|
+
Log.error "Cannot initialize Merona!!"
|
11
|
+
end
|
12
|
+
|
13
|
+
polling do
|
14
|
+
# write code here
|
15
|
+
|
16
|
+
$oid = 0
|
17
|
+
|
18
|
+
test = Server.new("test", 9916)
|
19
|
+
test.add_handler ChatHandler
|
20
|
+
test.add_handler PubsubHandler
|
21
|
+
test.add_handler SyncHandler
|
22
|
+
end
|
23
|
+
|
24
|
+
rescue
|
25
|
+
Log.error "[Error] : #{$!}"
|
26
|
+
end
|
data/frame/merona.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Merona entry
|
2
|
+
$LOAD_PATH << "../lib"
|
3
|
+
$LOAD_PATH << "."
|
4
|
+
|
5
|
+
def import(_path)
|
6
|
+
if _path[_path.length-1] == '*'
|
7
|
+
path = "../lib/" + _path
|
8
|
+
Dir[path[0..path.length-1] + "*.rb"].each {|file| require file }
|
9
|
+
path = "./" + _path
|
10
|
+
Dir[path[0..path.length-1] + "*.rb"].each {|file| require file }
|
11
|
+
else
|
12
|
+
require _path
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
import 'main.rb'
|
17
|
+
|
data/tests/test_chat.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'socket'
|
2
|
+
|
3
|
+
load '../lib/protocol/chat_protocol.rb'
|
4
|
+
load '../lib/packet/packet.rb'
|
5
|
+
load '../lib/packet/chat_packet.rb'
|
6
|
+
|
7
|
+
load 'test_util.rb'
|
8
|
+
|
9
|
+
if ARGV.size == 2
|
10
|
+
addr = ARGV[0]
|
11
|
+
port = ARGV[1]
|
12
|
+
else
|
13
|
+
addr = "localhost"
|
14
|
+
port = 9916
|
15
|
+
end
|
16
|
+
sock = TCPSocket.new addr, port
|
17
|
+
|
18
|
+
packet = ChatPacket.new
|
19
|
+
packet.id = Protocol::CHAT
|
20
|
+
packet.sender = "Aqwer"
|
21
|
+
packet.msg = "AEWF"
|
22
|
+
|
23
|
+
send_obj(sock, packet)
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'eventmachine'
|
2
|
+
|
3
|
+
load '../lib/packet/packet.rb'
|
4
|
+
load '../lib/protocol/pubsub_protocol.rb'
|
5
|
+
load '../lib/protocol/sync_protocol.rb'
|
6
|
+
|
7
|
+
load 'test_util.rb'
|
8
|
+
|
9
|
+
class Connection < EM::Connection
|
10
|
+
include EM::P::ObjectProtocol
|
11
|
+
|
12
|
+
def initialize(*args)
|
13
|
+
p = Packet.new
|
14
|
+
p.id = Protocol::SUBSCRIBE
|
15
|
+
send_object p
|
16
|
+
|
17
|
+
p.id = Protocol::SYNC
|
18
|
+
p["x"] = 1
|
19
|
+
p["y"] = 2
|
20
|
+
p["oid"] = 3
|
21
|
+
|
22
|
+
100.times do
|
23
|
+
send_object p
|
24
|
+
end
|
25
|
+
end
|
26
|
+
def unbind
|
27
|
+
end
|
28
|
+
|
29
|
+
def receive_object(obj)
|
30
|
+
p obj
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
EM::run do
|
35
|
+
EM::connect "localhost", 9916, Connection
|
36
|
+
end
|
37
|
+
|
38
|
+
while true
|
39
|
+
sleep 1
|
40
|
+
end
|
41
|
+
|
42
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
load '../lib/db/database.rb'
|
2
|
+
load '../lib/db/sqlite.rb'
|
3
|
+
|
4
|
+
load 'test_util.rb'
|
5
|
+
|
6
|
+
begin
|
7
|
+
|
8
|
+
db = SQLite.new("test.db")
|
9
|
+
|
10
|
+
# create table
|
11
|
+
db.execute "create table account(id TEXT, nick TEXT)"
|
12
|
+
db.insert("account", "id, nick", "'hello', 'world'")
|
13
|
+
db.insert("account", "id, nick", "'aaa', 'bbb'")
|
14
|
+
db.insert("account", "id, nick", "'foo', 'bar'")
|
15
|
+
|
16
|
+
# enum table data
|
17
|
+
rs = db.select("account", "*")
|
18
|
+
|
19
|
+
while (row = rs.next)
|
20
|
+
p row
|
21
|
+
end
|
22
|
+
|
23
|
+
rs.close
|
24
|
+
|
25
|
+
db.dispose
|
26
|
+
|
27
|
+
rescue SQLite3::Exception => e
|
28
|
+
puts "[error] " + e.to_s
|
29
|
+
end
|
data/tests/test_util.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merona
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -91,6 +91,16 @@ files:
|
|
91
91
|
- lib/server/server.rb
|
92
92
|
- lib/sharedmem/redis.rb
|
93
93
|
- lib/sharedmem/shared_memory.rb
|
94
|
+
- frame/config/config_connection.rb
|
95
|
+
- frame/config/config_db.rb
|
96
|
+
- frame/config/config_server.rb
|
97
|
+
- frame/config/config_sharedmem.rb
|
98
|
+
- frame/main.rb
|
99
|
+
- frame/merona.rb
|
100
|
+
- tests/test_chat.rb
|
101
|
+
- tests/test_connect.rb
|
102
|
+
- tests/test_sqlite.rb
|
103
|
+
- tests/test_util.rb
|
94
104
|
homepage: http://github.com/pjc0247/Merona
|
95
105
|
licenses: []
|
96
106
|
post_install_message:
|