Skip to content

SubwayRocketTeam/CornFlakes

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CornFlakes

packet serializer/unserializer for ruby Build Status

sample

packet_defination

C에서의 패킷

struct DummyPacket{
  int size, id;
  int dummy1;
  char dummy2[32+1]; // +1 for 'null'
  char dummy3[8+1]; // +1 for 'null'
};

CornFlakes를 이용해 위의 패킷을 구현.
size, id필드는 자동으로 기입됨.

class DummyPacket < Packet
  id PACKET_ID_DUMMY
  int :dummy1
  string :dummy2, 32 #string length
  string :dummy3, 8
end

serialize

pkt = DummyPacket.new
pkt.dummy1 = 1234
pkt.dummy2 = "hello world"
pkt.dummy3 = "serial"

send pkt.serialize

deserialize

def on_recv data
  pkt = DummyPacket.deserialize data
  
  puts pkt.dummy1
  puts pkt.dummy2
  puts pkt.dummy3
end

About

packet serializer/unserializer for ruby

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%