Exemplo n.º 1
0
        static void TaskTimer()
        {
            byte[] body = Encoding.UTF8.GetBytes("系统通知:这是一个测试!");

            UInt16 sn    = 0;
            Frame  frame = new Frame(Frame.MakeSerialNumber(true, sn), ((UInt16)Command.EMyCommand.SERVER_PUSH), body);

            while (!cts.IsCancellationRequested)
            {
                Thread.Sleep(1000);

                if (sn >= (UInt16)0x7fff)
                {
                    sn = 0;
                }
                else
                {
                    ++sn;
                }
                frame.UpdateFrameSerialNumber(Frame.MakeSerialNumber(true, sn));

                List <string> session_uuids = DemoRegisterSession.GetAll();
                foreach (string session_uuid in session_uuids)
                {
                    server.PushToClient(session_uuid, frame, (su, frm, rlt) => {
                        Console.WriteLine("服务器主动推送结果:" + rlt.ToString());
                    });
                }
            }
        }
Exemplo n.º 2
0
        public override void OnSessionStop()
        {
            DemoRegisterSession.UnRegisterSession(this.GetUUID());

            Console.WriteLine("MySession - OnSessionStop");
        }
Exemplo n.º 3
0
        public override void OnSessionStart()
        {
            Console.WriteLine("MySession - OnSessionStart");

            DemoRegisterSession.RegisterSession(this.GetUUID());
        }