示例#1
0
        //Client side calls this method to mark his status and start listen for his events
        public void StartListenForEvents()
        {
            string sessionId = CometWorker.GetSessionId(ClientId);

            //to make consistent log-in process lock the user status
            lock (MessageBroker.PreUserDefinitions)
            {
                string userName;
                MessageBroker.SessionUserPair.TryGetValue(sessionId, out userName);

                if (userName == null)//User Session Lost
                {
                    PokeIn.Comet.BrowserHelper.RedirectPage(ClientId, "/Sample/Home");
                    return;
                }

                MessageBroker.PreUserDefinitions.TryGetValue(userName, out userDefinition);
            }

            string jsonMethod = PokeIn.JSON.Method("SetTitle", "Hello " + userDefinition.Username + "! ");

            CometWorker.SendToClient(ClientId, jsonMethod);


            //Call Role Based User Initializitation
            InitializeUser();
        }