本文整理汇总了C#中IScheduler.Add方法的典型用法代码示例。如果您正苦于以下问题:C# IScheduler.Add方法的具体用法?C# IScheduler.Add怎么用?C# IScheduler.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IScheduler
的用法示例。
在下文中一共展示了IScheduler.Add方法的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 ();
};
}
示例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 ();
};
}