Esempio n. 1
0
        /// <summary>
        /// Forces all clients to refresh his ProtectedFilterList with the given filter list
        /// </summary>
        /// <param name="protectedFilterList">List of the new ForbiddenFilters</param>
        public void RefreshProtectedFilterLists(IList<Filter> protectedFilterList)
        {
            _LastProtectedFilterList = protectedFilterList;

            NetworkPackage pack = new NetworkPackage(Command.RefreshProtectedFilterList, protectedFilterList);

            foreach (TcpClient client in Clients)
                Send(client, pack);
        }
Esempio n. 2
0
        /// <summary>
        /// Forces the client to refresh his Forbbiden FilterList with the given filter list
        /// </summary>
        /// <param name="forbiddenFilterList">List of the new ProtectedFilters</param>
        public void RefreshForbiddenFilterLists(IList<Filter> forbiddenFilterList)
        {
            _LastForbiddenFilterList = forbiddenFilterList;

            NetworkPackage pack = new NetworkPackage(Command.RefreshForbiddenFilterList, forbiddenFilterList);

            foreach (TcpClient client in Clients)
                Send(client, pack);
        }
Esempio n. 3
0
        /// <summary>
        /// Methode which will be invoke by incoming messages
        /// </summary>
        /// <param name="package">The The received package</param>
        protected override void DataReceived(NetworkPackage package)
        {
            switch (package.Cmd)
            {
                case Command.RefreshProtectedFilterList:
                    IList<Filter> protectedList = package.Value as IList<Filter>;
                    if (protectedList == null) throw new ArgumentException("Value must be of type 'IList<Filter>'");

                    if (ProtectedFilterListRefreshed != null)
                        ProtectedFilterListRefreshed(protectedList);
                    break;

                case Command.RefreshForbiddenFilterList:
                    IList<Filter> forbiddenList = package.Value as IList<Filter>;
                    if (forbiddenList == null) throw new ArgumentException("Value must be of type 'IList<Filter>'");

                    if (ForbiddenFilterListRefreshed != null)
                        ForbiddenFilterListRefreshed(forbiddenList);
                    break;

                default:
                    throw new ArgumentException(string.Format("Coudn't handle '{0}'", package.Cmd));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Methode which will be invoke by incoming messages
        /// </summary>
        /// <param name="package">The The received package</param>
        protected override void DataReceived(NetworkPackage package)
        {
            switch (package.Cmd)
            {
                case Command.SaveProtocol:
                    Protocol protocol = package.Value as Protocol;
                    if (protocol == null) throw new ArgumentException("Value must be of type 'Protocol'");

                    if (ProtocolReceived != null)
                        ProtocolReceived((Protocol)package.Value);
                    break;

                default:
                    throw new ArgumentException(string.Format("Coudn't handle '{0}'", package.Cmd));
            }
        }
Esempio n. 5
0
        private void TaskForceServer_NewClientConnected(TcpClient newClient)
        {
            NetworkPackage pack;

            pack = new NetworkPackage(Command.RefreshProtectedFilterList, _LastProtectedFilterList);
            Send(newClient, pack);

            pack = new NetworkPackage(Command.RefreshForbiddenFilterList, _LastForbiddenFilterList);
            Send(newClient, pack);
        }
Esempio n. 6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="client">The client for the communication</param>
 /// <param name="package">The package to send</param>
 public SendParameters(TcpClient client, NetworkPackage package)
 {
     Package = package;
     Client = client;
 }
Esempio n. 7
0
 /// <summary>
 /// Methode which will be invoke by incoming messages
 /// </summary>
 /// <param name="package">The The received package</param>
 protected abstract void DataReceived(NetworkPackage package);
Esempio n. 8
0
 /// <summary>
 /// Sends an object to the client
 /// </summary>
 /// <param name="client">The receiver</param>
 /// <param name="package">The package to send</param>
 protected void Send(TcpClient client, NetworkPackage package)
 {
     ThreadPool.QueueUserWorkItem(Send, new SendParameters(client, package));
 }
Esempio n. 9
0
        /// <summary>
        /// Sends an Protocol object to the server
        /// </summary>
        /// <param name="protocol">The Protocol to send</param>
        public void SaveProtocol(Protocol protocol)
        {
            NetworkPackage pack = new NetworkPackage(Command.SaveProtocol, protocol);

            Send(pack);
        }