Пример #1
0
        private static void p_Server(object serverObject)
        {
            try
            {
                RemotingServer server = (RemotingServer)serverObject;

                // To this sample, I will require cryptography, and will only
                // accept RijndaelManaged and TripleDES. If I don't register a
                // valid cryptography, all cryptographies are valid.

                server.CryptographyMode = CryptographyMode.Required;
                server.RegisterAcceptedCryptography <RijndaelManaged>();
                server.RegisterAcceptedCryptography <TripleDESCryptoServiceProvider>();

                // Here I register the valid classes that the client can create
                // directly.
                //server.Register(typeof(IServer), typeof(SecureChat.Server.Server));
                server.Register(typeof(SecureChat.Common.IServer), typeof(SecureChat.Server.Server));
                // Here I start the server.
                server.Run(570);
            }
            catch (ObjectDisposedException)
            {
                // If during initialization the user press ENTER and disposes the
                // server, I will simple ignore the exception and finish the thread.
            }
        }
Пример #2
0
        public Server()
        {
            fServer = new RemotingServer();
            fServer.RegisterStaticMethod("GetServer", typeof(Server).GetMethod("GetInstance"));
            fServer.CryptographyMode = CryptographyMode.Required;
            fServer.RegisterAcceptedCryptography <RijndaelManaged>();
            fServer.MustUseAsyncVoidCalls = true;

            fServer.UserChannelCreated += p_UserChannelCreated;

            UnlimitedThreadPool.Run
            (
                delegate
            {
                try
                {
                    fServer.Run(570);
                }
                catch
                {
                }
            }
            );
        }