public InternalProfile(ProfileRegistry enclosingInstance)
 {
     InitBlock(enclosingInstance);
 }
 private void InitBlock(ProfileRegistry enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
 }
Exemple #3
0
        /// <summary>Method complete</summary>
        /// <exception cref="BEEPException" />
        public virtual void complete(IChannel channel, SessionCredential localCred, SessionCredential peerCred, SessionTuningProperties tuning, ProfileRegistry registry, object argument)
        {
            try
            {
                log.debug("TuningProfile.complete");

                SessionImpl s = (SessionImpl) channel.Session;

                s.reset(localCred, peerCred, tuning, registry, argument);
                tuningChannels.Remove(channel);
            }
            catch (System.Exception x)
            {
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
                abort(new BEEPError(BEEPStatusCode.REQUESTED_ACTION_ABORTED, "TuningProfile.complete failure\n" + x.Message), channel);
            }
        }
Exemple #4
0
 /// <summary>Method reset
 /// </summary>
 /// <exception cref="BEEPException" />
 protected internal static ISession reset(ISession session, SessionCredential localCred, SessionCredential peerCred, SessionTuningProperties tuning, ProfileRegistry registry, object argument)
 {
     return ((SessionImpl) session).reset(localCred, peerCred, tuning, registry, argument);
 }
Exemple #5
0
        protected internal override ISession reset(SessionCredential localCred, SessionCredential peerCred, SessionTuningProperties tuning, ProfileRegistry reg, object argument)
        {
            lock(this)
            {

                if (log.isTraceEnabled())
                {
                    log.trace("Reset as " + (Initiator?"INITIATOR":"LISTENER"));
                }

                System.Net.Sockets.TcpClient s = argument as System.Net.Sockets.TcpClient;

                if(s == null)
                {
                    s = this.socket;
                }

                if (reg == null)
                {
                    reg = this.ProfileRegistry;
                }

                ISession newSession = new TCPSession(s, reg, (Initiator?CHANNEL_START_ODD:CHANNEL_START_EVEN), localCred, peerCred, tuning, null);

                this.fireSessionReset(newSession);

                return newSession;
            }
        }
Exemple #6
0
        /// <param name="sock">the Socket for this TCPConnection</param>
        /// <param name="registry">the ProfileRegistry (set of profiles) to be used on
        /// this Session</param>
        /// <param name="firstChannel">the integer indicating the
        /// ordinality for this Peer, which determines whether Channels
        /// started by this peer have odd or even numbers.</param>
        /// <param name="localCred"></param>
        /// <param name="peerCred"></param>
        /// <remarks>
        /// The hack-ish part of this is the credential parameter.  Here's
        /// the deal.  (1) TCPSessionCreator has public methods that don't
        /// expose the credential (2) Therefore if it's called by the User,
        /// it can only have a null credential.  (3) If it's called via a
        /// Tuning Profile reset though, it can have a real value.  (4)
        /// When that's the case, we call a 'different' init method that
        /// doesn't block the thread of the former (soon to die) session.
        /// </remarks>
        /// <exception cref="BEEPException" />
        private TCPSession(System.Net.Sockets.TcpClient sock, ProfileRegistry registry, int firstChannel, SessionCredential localCred, SessionCredential peerCred, SessionTuningProperties tuning, string servername)
            : base(registry, firstChannel, localCred, peerCred, tuning, servername)
        {
            InitBlock();

            socket = sock;
            writerLock = new object();

            if ((peerCred != null) || (localCred != null) || (tuning != null))
            {
                tuningInit();
            }
            else
            {
                init();
            }

            try
            {
                socket.ReceiveBufferSize = MAX_RECEIVE_BUFFER_SIZE;
            }
            catch (System.Exception)
            {
                log.debug("Socket doesn't support setting receive buffer size");
            }
        }
Exemple #7
0
 /// <summary>Creates a TCPSession for a Socket that was created by
 /// listening and accepting a connection.</summary>
 /// <param name="sock"></param>
 /// <param name="registry"></param>
 /// <exception cref="BEEPException" />
 public static TCPSession createListener(System.Net.Sockets.TcpClient sock, ProfileRegistry registry)
 {
     return new TCPSession(sock, (ProfileRegistry) registry.Clone(), CHANNEL_START_EVEN, null, null, null, null);
 }
Exemple #8
0
 /// <summary>Creates a TCPSession for a Socket that was created by
 /// initiating a connection.</summary>
 /// <param name="sock"></param>
 /// <param name="registry"></param>
 /// <exception cref="BEEPException" />
 public static TCPSession createInitiator(System.Net.Sockets.TcpClient sock, ProfileRegistry registry)
 {
     return createInitiator(sock, registry, null);
 }
Exemple #9
0
 /// <summary>Creates a TCPSession for a Socket that was created by
 /// initiating a connection.</summary>
 /// <param name="sock"></param>
 /// <param name="registry"></param>
 /// <param name="servername"></param>
 /// <exception cref="BEEPException" />
 public static TCPSession createInitiator(System.Net.Sockets.TcpClient sock, ProfileRegistry registry, string servername)
 {
     return new TCPSession(sock, (ProfileRegistry) registry.Clone(), CHANNEL_START_ODD, null, null, null, servername);
 }
Exemple #10
0
		/// <summary>This method is used by a tuning profile to reset the session after the
		/// tuning is complete.</summary>
		/// <returns>A new <code>Session</code> with the tuning complete.</returns>
		protected internal abstract ISession reset(SessionCredential localCred, SessionCredential peerCred, SessionTuningProperties tuning, ProfileRegistry registry, object argument);
Exemple #11
0
		/// <summary>Default Session Constructor.  A relationship between peers - a session -
		/// consists of a set of profiles they share in common, and an ordinality
		/// (to prevent new channel collision) so that the initiator starts odd
		/// channels and the listener starts channels with even numbers.</summary>
		/// <param name="registry">The Profile Registry summarizing the profiles this
		/// Session will support</param>
		/// <param name="firstChannel">used internally in the API, an indication of the
		/// ordinality of the channels this peer can start, odd, or even.</param>
		/// <param name="localCred"></param>
		/// <param name="peerCred"></param>
		/// <param name="tuning"></param>
		/// <param name="serverName"></param>
		protected internal SessionImpl(ProfileRegistry registry, int firstChannel, SessionCredential localCred, SessionCredential peerCred, SessionTuningProperties tuning, string serverName)
		{
			log = LogFactory.getLog(this.GetType());

			state = core.SessionState.SESSION_STATE_INITIALIZED;
			localCredential = localCred;
			peerCredential = peerCred;
			nextChannelNumber = firstChannel;
			overflow = false;
			profileRegistry = registry;
			channels = new System.Collections.Hashtable(DEFAULT_CHANNELS_SIZE);
			properties = new System.Collections.Hashtable(DEFAULT_PROPERTIES_SIZE);
			tuningProperties = tuning;
			this.serverName = serverName;
		}