Ejemplo n.º 1
0
 private static bool OnProcessAccountReg(NetServer server, int id, NetIncomingMessage msg)
 {
     Msg_AccountReg r        = new Msg_AccountReg();
     r.R(msg);
     Msg_AccountRegRsp rr    = new Msg_AccountRegRsp();
     rr.suc                  = true;
     rr.detail               = r.name + r.pass;
     SendMessage(server, rr, msg.SenderConnection);
     return true;
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            NetClientHelper netClient = new NetClientHelper();
            netClient.Connect("127.0.0.1", 48360);
            netClient.InternalMessage += (sender, e) =>
            {
                Console.WriteLine(e.Msg);
            };
            netClient.StatusMessage += (sender, e) =>
            {
                Console.WriteLine(e.Status);
                Console.WriteLine(e.Reason);
            };
            netClient.DataMessage += (sender, e) =>
            {
                if (e.Msg.Id == MsgId.ChatToAll)
                {
                    Msg_ChatToAll c = (Msg_ChatToAll)e.Msg;
                    Console.WriteLine(c.Id);
                    Console.WriteLine(c.chatMsg);
                }
                else if (e.Msg.Id == MsgId.AccountRegRsp)
                {
                    Msg_AccountRegRsp c = (Msg_AccountRegRsp)e.Msg;
                    Console.WriteLine(c.Id);
                    Console.WriteLine(c.suc);
                    Console.WriteLine(c.detail);
                }
            };

            var timer = new System.Timers.Timer(5000);
            timer.Elapsed += (sender, e) =>
            {
                Msg_ChatToAll chat = new Msg_ChatToAll();
                chat.chatMsg = "hehe";
                netClient.SendMessage(chat);
            };
            timer.Start();

            var timer2 = new System.Timers.Timer(6000);
            timer2.Elapsed += (sender, e) =>
            {
                Msg_AccountReg reg = new Msg_AccountReg();
                reg.name = "zapline";
                reg.pass = "******";
                netClient.SendMessage(reg);
            };
            timer2.Start();

            while (true)
            {
                netClient.Update();
                Thread.Sleep(1);
            }
        }