Beispiel #1
0
        static void CheckMessages()
        {
            PokeInWCFMessageFormat[] results = null;

            try
            {
                results = proxy.PingMessages();
            }
            catch (System.Net.WebException e)
            {
                ServerConnected = false;
                CometWorker.SendToAll("UpdateServiceStatus(" + ServerConnected.ToString().ToLower() + ");");
                ConnectToWCF();
            }
            if (results != null)
            {
                if (results.Length > 0)
                {
                    foreach (PokeInWCFMessageFormat message in results)
                    {
                        CometWorker.SendToClients(message.Clients, message.Message);
                    }
                }
            }

            //check messages every 1 second
            //You may implement a WCF instance to both side for efficiency or check out the Multiple Server sample project
            Thread.Sleep(1000);
            CheckMessages();
        }
Beispiel #2
0
        public static void UpdateAdminScreens(string userName, int appleCount)
        {
            lock (AdminClientIDs)
            {
                if (AdminClientIDs.Count > 0)//admin logged in
                {
                    string jm = JSON.Method("UpdateUserRequest", userName, appleCount);

                    //send message to each admin screen
                    CometWorker.SendToClients(AdminClientIDs.ToArray(), jm);
                }
            }
        }