// [ protocol : 4 // k : 4 // len : 4 // index : 4 // len : 4 // opcode : 4 // value : // ... // index : 4 private void ExecFrame() { int k; NetFrame frame; if (_queue.Dequeue(out k, out frame) == 1) { try { int offset = 0; int index = 0, len = 0; offset = NetUnpack.Unpackli(frame.buffer, offset, out index); offset = NetUnpack.Unpackli(frame.buffer, offset, out len); OpCodeParse(index, frame.buffer, offset, len); } catch (Exception ex) { k = _queue.BackK(); int len = 8; byte[] msg = new byte[len]; int offset = 0; offset = NetPack.Packli(msg, offset, (int)ProtocolType.PT_FETCHK); offset = NetPack.Packli(msg, offset, k); _ctx.SendUdp(msg, 0, len); } } else { int len = 8; byte[] msg = new byte[len]; int offset = 0; offset = NetPack.Packli(msg, offset, (int)ProtocolType.PT_FETCHK); offset = NetPack.Packli(msg, offset, k); _ctx.SendUdp(msg, 0, len); } }
public GameController(Context ctx) : base(ctx) { _ui = new UIRootActor(_ctx, this); // 4, protocol _syncmsg1 = new byte[4]; NetPack.Packli(_syncmsg1, 0, 1); //EventListenerCmd listener1 = new EventListenerCmd(MyEventCmd.EVENT_SETUP_SCENE, SetupScene); //_ctx.EventDispatcher.AddCmdEventListener(listener1); //EventListenerCmd listener2 = new EventListenerCmd(MyEventCmd.EVENT_SETUP_MAP, SetupMap); //_ctx.EventDispatcher.AddCmdEventListener(listener2); //EventListenerCmd listener3 = new EventListenerCmd(MyEventCmd.EVENT_SETUP_VIEW, SetupCamera); //_ctx.EventDispatcher.AddCmdEventListener(listener3); }
public GameController(Context ctx) : base(ctx) { _systems = new Entitas.Systems(); _indexsystem = new IndexSystem(Contexts.sharedInstance.game); _mapsystem = new MapSystem(Contexts.sharedInstance.game); _joinsystem = new JoinSystem(Contexts.sharedInstance.game); _myplayersystem = new MyPlayerSystem(Contexts.sharedInstance.game); _systems.Add(_indexsystem) .Add(_mapsystem) .Add(_joinsystem) .Add(_myplayersystem); // 4, protocol _syncmsg1 = new byte[4]; NetPack.Packli(_syncmsg1, 0, 1); EventListenerCmd listener2 = new EventListenerCmd(MyEventCmd.EVENT_SETUP_MAP, SetupMap); _ctx.EventDispatcher.AddCmdEventListener(listener2); //EventListenerCmd listener3 = new EventListenerCmd(MyEventCmd.EVENT_SETUP_VIEW, SetupCamera); //_ctx.EventDispatcher.AddCmdEventListener(listener3); }