コード例 #1
0
ファイル: CMClient.cs プロジェクト: sherpic/SteamKit
        /// <summary>
        /// Initializes a new instance of the <see cref="CMClient"/> class with a specific connection type.
        /// </summary>
        /// <param name="type">The connection type to use.</param>
        /// <exception cref="NotSupportedException">
        /// The provided <see cref="ProtocolType"/> is not supported.
        /// Only Tcp and Udp are available.
        /// </exception>
        public CMClient(ProtocolType type = ProtocolType.Tcp)
        {
            serverMap = new Dictionary <EServerType, List <IPEndPoint> >();

            // our default timeout
            ConnectionTimeout = TimeSpan.FromSeconds(5);

            switch (type)
            {
            case ProtocolType.Tcp:
                connection = new TcpConnection();
                break;

            case ProtocolType.Udp:
                connection = new UdpConnection();
                break;

            default:
                throw new NotSupportedException("The provided protocol type is not supported. Only Tcp and Udp are available.");
            }

            connection.NetMsgReceived += NetMsgReceived;
            connection.Connected      += Connected;
            connection.Disconnected   += Disconnected;

            heartBeatFunc = new ScheduledFunction(() =>
            {
                Send(new ClientMsgProtobuf <CMsgClientHeartBeat>(EMsg.ClientHeartBeat));
            });
        }
コード例 #2
0
 public ScheduledFunction <Instant> AddTest(
     [NotNull] ScheduledFunction <Instant> scheduledFunction,
     [NotNull] IEnumerable <Duration> expectedResults)
 {
     _tests.Add(scheduledFunction, expectedResults);
     return(scheduledFunction);
 }
コード例 #3
0
 // Same as scheduled (add) function above but for putting in a full entry.
 public void Schedule(ScheduledFunction entry)
 {
     if (entry != null)
     {
         m_actions.Add(entry);
     }
 }
コード例 #4
0
ファイル: CMClient.cs プロジェクト: oxters168/SteamKit
        /// <summary>
        /// Initializes a new instance of the <see cref="CMClient"/> class with a specific configuration.
        /// </summary>
        /// <param name="configuration">The configuration to use for this client.</param>
        /// <exception cref="ArgumentNullException">The configuration object is <c>null</c></exception>
        public CMClient(SteamConfiguration configuration)
        {
            Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
            serverMap     = new Dictionary <EServerType, HashSet <IPEndPoint> >();

            heartBeatFunc = new ScheduledFunction(() =>
            {
                Send(new ClientMsgProtobuf <CMsgClientHeartBeat>(EMsg.ClientHeartBeat));
            });
        }
コード例 #5
0
ファイル: Scheduler.cs プロジェクト: kovacsgabor55/marsara
 /// <summary>
 /// Adds a scheduled function to this scheduler.
 /// </summary>
 /// <param name="function">The function to be added.</param>
 /// <remarks>
 /// If the given function has already been added to this scheduler then this function has no effect.
 /// </remarks>
 public void AddScheduledFunction(ScheduledFunction function)
 {
     lock (this.registeredFunctions)
     {
         if (!this.registeredFunctions.Contains(function))
         {
             this.registeredFunctions.Add(function);
         }
     }
 }
コード例 #6
0
ファイル: CMClient.cs プロジェクト: ppker/SteamKit
        /// <summary>
        /// Initializes a new instance of the <see cref="CMClient"/> class with a specific configuration.
        /// </summary>
        /// <param name="configuration">The configuration to use for this client.</param>
        /// <param name="identifier">A specific identifier to be used to uniquely identify this instance.</param>
        /// <exception cref="ArgumentNullException">The configuration object or identifier is <c>null</c></exception>
        /// <exception cref="ArgumentException">The identifier is an empty string</exception>
        public CMClient(SteamConfiguration configuration, string identifier)
        {
            Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));

            if (identifier is null)
            {
                throw new ArgumentNullException(nameof(identifier));
            }
            if (identifier.Length == 0)
            {
                throw new ArgumentException("Identifer must not be empty.", nameof(identifier));
            }

            ID = identifier;

            heartBeatFunc = new ScheduledFunction(() =>
            {
                Send(new ClientMsgProtobuf <CMsgClientHeartBeat>(EMsg.ClientHeartBeat));
            });
        }
コード例 #7
0
        private void scroll_to_smooth(DOMPoint location)
        {/* https://www.w3.org/TR/cssom-view-1/#concept-smooth-scroll */
            if (smooth_scroller == null)
            {
                smooth_scroller = new ScheduledFunction(this._smooth_scroll_tick, TimeSpan.FromMilliseconds(2));
            }

            /* Find distance between current position and target position */
            double distX = location.x - ScrollX;
            double distY = location.y - ScrollY;

            /* Calculate our delta step size so we know how much to add to our scroll position per tick */
            double deltaX = distX / (double)Smooth_Scroll_Anim_Time.Ticks;
            double deltaY = distY / (double)Smooth_Scroll_Anim_Time.Ticks;

            Smooth_Scroll_Target   = location;
            Smooth_Scroll_Distance = new DOMPoint(distX, distY);

            /* Set the end time */
            Smooth_Scroll_End_Time = (DateTime.Now + Smooth_Scroll_Anim_Time).Ticks;
            /* Start scrolling */
            smooth_scroller.Start();
        }
コード例 #8
0
ファイル: CMClient.cs プロジェクト: wheybags/steamirc
        /// <summary>
        /// Initializes a new instance of the <see cref="CMClient"/> class with a specific connection type.
        /// </summary>
        /// <param name="type">The connection type to use.</param>
        /// <exception cref="NotSupportedException">
        /// The provided <see cref="ProtocolType"/> is not supported.
        /// Only Tcp and Udp are available.
        /// </exception>
        public CMClient( ProtocolType type = ProtocolType.Tcp )
        {
            serverMap = new Dictionary<EServerType, List<IPEndPoint>>();

            switch ( type )
            {
                case ProtocolType.Tcp:
                    connection = new TcpConnection();
                    break;

                case ProtocolType.Udp:
                    connection = new UdpConnection();
                    break;

                default:
                    throw new NotSupportedException( "The provided protocol type is not supported. Only Tcp and Udp are available." );
            }

            connection.NetMsgReceived += NetMsgReceived;
            connection.Disconnected += Disconnected;
            connection.Connected += Connected;
            heartBeatFunc = new ScheduledFunction( () =>
            {
                Send( new ClientMsgProtobuf<CMsgClientHeartBeat>( EMsg.ClientHeartBeat ) );
            } );
        }
コード例 #9
0
 // Same as scheduled (add) function above but for putting in a full entry.
 public void Schedule( ScheduledFunction entry )
 {
     if( entry != null )
     {
         m_actions.Add( entry );
     }
 }
コード例 #10
0
 // Schedule (add) a function delegate (function), to execute at time (time) from the
 // start of this class instance.
 public void Schedule( float time, ScheduledFunction.function function )
 {
     Schedule( new ScheduledFunction( time, function ) );
 }
コード例 #11
0
 public ScheduledFunction <Instant> AddTest([NotNull] ISchedule schedule, [NotNull] IEnumerable <Duration> expectedResults, ScheduledFunction <Instant> .SchedulableDueCancellableFunctionAsync function = null)
 {
     Assert.IsNotNull(schedule);
     Assert.IsNotNull(expectedResults);
     return(AddTest(Scheduler.Add(function ?? TestFunction, schedule, expectedResults.Count()), expectedResults));
 }
コード例 #12
0
ファイル: Scheduler.cs プロジェクト: kovacsgabor55/marsara
 /// <summary>
 /// Removes the given scheduled function from this scheduler.
 /// </summary>
 /// <param name="function">The function to be removed.</param>
 /// <remarks>
 /// If the given function has already been removed from this scheduler then this function has no effect.
 /// </remarks>
 public void RemoveScheduledFunction(ScheduledFunction function)
 {
     lock (this.registeredFunctions) { this.registeredFunctions.Remove(function); }
 }
コード例 #13
0
 public ScheduledFunction<Instant> AddTest([NotNull] ISchedule schedule, [NotNull] IEnumerable<Duration> expectedResults, ScheduledFunction<Instant>.SchedulableDueCancellableFunctionAsync function = null)
 {
     Assert.IsNotNull(schedule);
     Assert.IsNotNull(expectedResults);
     return AddTest(Scheduler.Add(function ?? TestFunction, schedule, expectedResults.Count()), expectedResults);
 }