public MoveServer()
    {
        MsgDictDefine.Reg(
            "JsonMsg.MsgMove",
            "JsonMsg.MsgPing"
            );

        var packer = new JsonMsgPacker();

        packer.MsgDefine = MsgDictDefine.Instance;
        _netMgr.Packer   = packer;
        _netMgr.AddMsgHandler(this);
        _netMgr.StartLoop(8888);
    }
Esempio n. 2
0
        // Start is called before the first frame update
        void Start()
        {
            MsgDictDefine.Reg(
                "JsonMsg.MsgMove",
                "JsonMsg.MsgPing"
                );

            var packer = new JsonMsgPacker();

            packer.MsgDefine = MsgDictDefine.Instance;
            _netMgr.Packer   = packer;
            _netMgr.NetEventDispatcher.AddListener(NetManager.NetEvent.ConnectSuccess, OnConnectSuccess);
            _netMgr.NetEventDispatcher.AddListener(NetManager.NetEvent.ConnectFail, OnConnectFail);
            _netMgr.NetEventDispatcher.AddListener(NetManager.NetEvent.Close, OnClose);
            _netMgr.NetMsgDispatcher.AddListener(_netMgr.Packer.GetMsgName(typeof(MsgMove)), OnMsgMove);
            _netMgr.EnableHeartbeat(() => { return(new MsgPing()); });
            _netMgr.Connect("127.0.0.1", 8888);
            StartCoroutine(RandMove());
        }