示例#1
0
        /// <summary>
        /// Que a WebMessage to a single WebClient
        /// </summary>
        /// <param name="publicKey">The PublicKey of the WebClient</param>
        /// <param name="message">The Message</param>
        public void QueMessage(Guid publicKey, WebMessage message)
        {
            WebClient client = Clients.SingleOrDefault(c => c.PublicKey.Equals(publicKey));

            if (null != client)
            {
                client.Que(message);
            }
        }
示例#2
0
        void ProcessListen(Guid loginToken, HttpContextAdapter adapter)
        {
            WebClient client;

            //If we have a client
            if (m_Clients.TryGetValue(loginToken, out client))
            {
                //Being the ListenRequest
                client.BeginListenRequest(adapter);
            }
            else
            {
                //Create a client and being the ListenRequest
                client = new WebClient(loginToken, this);

                //Assign the application UserData
                client.UserData = new UserWrapper(client);

                //Ensure only one client is added in a listen
                lock (m_Clients)
                {
                    //Add the client o the m_Clients Dictionary
                    m_Clients.Add(client.LoginToken, client);
                }

                //Give the client the most up to date WebServerInfo
                client.Que(new WebMessage("webServerInfo", ToJSON()));

                //Instuct the client he is connected
                client.Que(CreateEnterExitMessage(client, false));

                //Begin his listenRequest
                client.BeginListenRequest(adapter);

                //Give the connected users to all users
                SendAll(CreateUserList());
            }
        }
示例#3
0
        public void Ban(WebClient client)
        {
            if (Banned.Contains(client))
            {
                return;
            }

            //Ensure only 1 thread in m_Banned
            lock (m_Banned)
            {
                m_Banned.Add(client);
            }

            //If the user was present then make him leave
            if (Present.Contains(client))
            {
                //Tell the client he was banned
                client.Que(new WebMessage("chatBan", ToJSON()));
                LeaveChat(client);
            }
        }