예제 #1
0
        public void NetFrameSetDataSample()
        {
            NetFrame frame = new NetFrame();

            byte[] data = Tools.HexStrToByteArr("BD 11 11 11 11 11 11 88 88 88 88 88 88 D1 01 FC FF 22 11 11 11 11 11 12 11 22 33", ' ');
            frame.SetData(data);
        }
예제 #2
0
        public void NetFrameGetDataSample()
        {
            NetFrame frame = new NetFrame();

            frame.Ctrl.RoutingInstruction = 1;
            frame.Ctrl.FrameType          = EmNetFrameType.Command;
            frame.Ctrl.TargetAddrMode     = EmAddrLen.Six;
            frame.Ctrl.SourceAddrMode     = EmAddrLen.Six;

            frame.TargetAddr.Value = new byte[] { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11 };

            frame.SourceAddr.Value = new byte[] { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88 };

            frame.Seq.Value = 13;
            frame.Radius    = 1;

            /*
             * frame.RouteInfo.Add(new NetAddr() { AddrMode = EmNetAddrLen.Six, Value = new byte[] {0x11, 0x11, 0x11, 0x11, 0x11, 0x22} });
             * frame.RouteInfo.RouteIndex = 0;
             */
            // 这里和上面两句有同样的效果
            frame.RouteInfo.SetData(Tools.HexStrToByteArr("01 FC FF 22 11 11 11 11 11", ' '));

            NetCmd netCmd = new NetCmd();

            netCmd.CmdID       = EmNetCmdID.ConfigChildNodes;
            netCmd.CmdDu.Value = new byte[] { 0x11, 0x22, 0x33 };
            frame.Du           = netCmd;


            byte[] data = frame.GetData();
            frame.ToString();
        }
예제 #3
0
        public int GetID(NetFrame.UserToken token)
        {
            //玩家不在线则返回-1
            if (!onlineAccMap.ContainsKey(token)) return -1;

            //返回账号ID
            return accMap[onlineAccMap[token]].ID;
        }
예제 #4
0
        public void MacFrameGetDataSample1()
        {
            MacFrame frame = new MacFrame();

            frame.Ctrl.FrameType      = EmMacFrameType.Data;
            frame.Ctrl.HasExtension   = true;
            frame.Ctrl.TargetAddrMode = EmAddrLen.Six;
            frame.Ctrl.SourceAddrMode = EmAddrLen.Six;

            frame.Seq.Value        = 110;
            frame.PanID            = 0x6771;
            frame.TargetAddr.Value = new byte[] { 0x11, 0x11, 0x11, 0x11, 0x11, 0x22 };
            frame.SourceAddr.Value = new byte[] { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88 };

            frame.Extension                  = new MacExtension();
            frame.Extension.ExtLength        = 10;
            frame.Extension.ExtContent.Value = Tools.HexStrToByteArr("46 43 20 00 07 00 F4 03 4D B9", ' ');

            NetFrame nf = new NetFrame();

            nf.Ctrl.FrameType          = EmNetFrameType.Data;
            nf.Ctrl.RoutingInstruction = 1;
            nf.Ctrl.TargetAddrMode     = EmAddrLen.Six;
            nf.Ctrl.SourceAddrMode     = EmAddrLen.Six;
            nf.TargetAddr.Value        = new byte[] { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11 };
            nf.SourceAddr.Value        = new byte[] { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88 };
            nf.Seq.Value = 13;
            nf.Radius    = 2;
            nf.RouteInfo.Add(new NetAddr()
            {
                AddrMode = EmAddrLen.Six, Value = new byte[] { 0x11, 0x11, 0x11, 0x11, 0x11, 0x22 }
            });
            frame.Du = nf;

            ApsFrame af = new ApsFrame();

            af.Fcd.Ftd   = EmApsFcdFtd.Forward;
            af.Fcd.Oei   = 0;
            af.Seq.Value = 2;
            af.Dui       = (byte)EmApsFcdFtdDti.Auto;
            af.Du.Value  = Tools.HexStrToByteArr("FE FE FE FE 68 11 11 11 11 11 11 68 11 04 34 34 33 37 1D 16", ' ');
            nf.Du        = af;

            byte[] data = frame.GetData();
        }
    public override void DoUpdate()
    {
        PluginUtilities.ProfilerBegin("FrameServerManager.DoUpdate");
        base.DoUpdate();

        if (this.ElapseTime(deltaTime))
        {
            frameInputList.Clear();
            foreach (var server in servers.Values)
            {
                var list = server.receivePacketList;
                frameInputPlayerList.Clear();

                for (int i = 0; i < list.Count; i++)
                {
                    var frame = NetFrame.decoder(list[i].data);
                    for (int j = 0; j < frame.inputDatas.Length; j++)
                    {
                        frameInputPlayerList.Add(frame.inputDatas[j]);
                    }
                    frameInputPlayerList.Sort((NetFrameInput a, NetFrameInput b) =>
                    {
                        return(a.index - b.index);
                    });
                    frameInputList.AddRange(frameInputPlayerList);

                    LogUtils.Log("Net server recv frame, input =", frame.inputDatas);
                }

                list.Clear();
            }

            NetFrameNotify notify = new NetFrameNotify();
            notify.frameId    = frameId;
            notify.inputDatas = frameInputList.ToArray();

            Notify(notify);

            frameId += 1;
        }
        PluginUtilities.ProfilerEnd();
    }
예제 #6
0
 public void Online(NetFrame.UserToken token, string account)
 {
     //在事务层已经判断,所以直接添加账号映射
     onlineAccMap.Add(token, account);
 }
예제 #7
0
 public void Offline(NetFrame.UserToken token)
 {
     //如果当前连接登录,则移除
     if (onlineAccMap.ContainsKey(token)) onlineAccMap.Remove(token);
 }