当前位置: 首页>>代码示例>>C#>>正文


C# IScheduler.Remove方法代码示例

本文整理汇总了C#中IScheduler.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# IScheduler.Remove方法的具体用法?C# IScheduler.Remove怎么用?C# IScheduler.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IScheduler的用法示例。


在下文中一共展示了IScheduler.Remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: KRPCServer

        internal KRPCServer(IPAddress address, ushort rpcPort, ushort streamPort)
        {
            rpcTcpServer = new TCPServer ("RPCServer", address, rpcPort);
            streamTcpServer = new TCPServer ("StreamServer", address, streamPort);
            rpcServer = new RPCServer (rpcTcpServer);
            streamServer = new StreamServer (streamTcpServer);
            clientScheduler = new RoundRobinScheduler<IClient<Request,Response>> ();
            continuations = new List<RequestContinuation> ();
            streamRequests = new Dictionary<IClient<byte,StreamMessage>,IList<StreamRequest>> ();

            // Tie events to underlying server
            rpcServer.OnStarted += (s, e) => {
                if (OnStarted != null)
                    OnStarted (this, EventArgs.Empty);
            };
            rpcServer.OnStopped += (s, e) => {
                if (OnStopped != null)
                    OnStopped (this, EventArgs.Empty);
            };
            rpcServer.OnClientRequestingConnection += (s, e) => {
                if (OnClientRequestingConnection != null)
                    OnClientRequestingConnection (s, e);
            };
            rpcServer.OnClientConnected += (s, e) => {
                if (OnClientConnected != null)
                    OnClientConnected (s, e);
            };
            rpcServer.OnClientDisconnected += (s, e) => {
                if (OnClientDisconnected != null)
                    OnClientDisconnected (s, e);
            };

            // Add/remove clients from the scheduler
            rpcServer.OnClientConnected += (s, e) => clientScheduler.Add (e.Client);
            rpcServer.OnClientDisconnected += (s, e) => clientScheduler.Remove (e.Client);

            // Add/remove clients from the list of stream requests
            streamServer.OnClientConnected += (s, e) => streamRequests [e.Client] = new List<StreamRequest> ();
            streamServer.OnClientDisconnected += (s, e) => streamRequests.Remove (e.Client);

            // Validate stream client identifiers
            streamServer.OnClientRequestingConnection += (s, e) => {
                if (rpcServer.Clients.Where (c => c.Guid == e.Client.Guid).Any ())
                    e.Request.Allow ();
                else
                    e.Request.Deny ();
            };
        }
开发者ID:602p,项目名称:krpc,代码行数:48,代码来源:KRPCServer.cs

示例2: KRPCServer

        internal KRPCServer(IPAddress address, ushort rpcPort, ushort streamPort,
                             bool oneRPCPerUpdate = false, uint maxTimePerUpdate = 5000, bool adaptiveRateControl = true, bool blockingRecv = true, uint recvTimeout = 1000)
        {
            rpcTcpServer = new TCPServer ("RPCServer", address, rpcPort);
            streamTcpServer = new TCPServer ("StreamServer", address, streamPort);
            rpcServer = new RPCServer (rpcTcpServer);
            streamServer = new StreamServer (streamTcpServer);
            clientScheduler = new RoundRobinScheduler<IClient<Request,Response>> ();
            continuations = new List<RequestContinuation> ();
            streamRequests = new Dictionary<IClient<byte,StreamMessage>,IList<StreamRequest>> ();

            OneRPCPerUpdate = oneRPCPerUpdate;
            MaxTimePerUpdate = maxTimePerUpdate;
            AdaptiveRateControl = adaptiveRateControl;
            BlockingRecv = blockingRecv;
            RecvTimeout = recvTimeout;

            // Tie events to underlying server
            rpcServer.OnStarted += (s, e) => {
                if (OnStarted != null)
                    OnStarted (this, EventArgs.Empty);
            };
            rpcServer.OnStopped += (s, e) => {
                if (OnStopped != null)
                    OnStopped (this, EventArgs.Empty);
            };
            rpcServer.OnClientRequestingConnection += (s, e) => {
                if (OnClientRequestingConnection != null)
                    OnClientRequestingConnection (s, e);
            };
            rpcServer.OnClientConnected += (s, e) => {
                if (OnClientConnected != null)
                    OnClientConnected (s, e);
            };
            rpcServer.OnClientDisconnected += (s, e) => {
                if (OnClientDisconnected != null)
                    OnClientDisconnected (s, e);
            };

            // Add/remove clients from the scheduler
            rpcServer.OnClientConnected += (s, e) => clientScheduler.Add (e.Client);
            rpcServer.OnClientDisconnected += (s, e) => clientScheduler.Remove (e.Client);

            // Add/remove clients from the list of stream requests
            streamServer.OnClientConnected += (s, e) => streamRequests [e.Client] = new List<StreamRequest> ();
            streamServer.OnClientDisconnected += (s, e) => streamRequests.Remove (e.Client);

            // Validate stream client identifiers
            streamServer.OnClientRequestingConnection += (s, e) => {
                if (rpcServer.Clients.Where (c => c.Guid == e.Client.Guid).Any ())
                    e.Request.Allow ();
                else
                    e.Request.Deny ();
            };
        }
开发者ID:Outurnate,项目名称:krpc,代码行数:55,代码来源:KRPCServer.cs


注:本文中的IScheduler.Remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。