private static void SendResponse(Task previous, ServerTransport transport, ServerResponseContext context, Tuple <RpcServer, long, int?, string> sessionState) { if (context == null) { if (previous.IsFaulted) { try { previous.Exception.Handle(inner => inner is OperationCanceledException); } catch (AggregateException exception) { InvocationHelper.HandleInvocationException( sessionState.Item2, MessageType.Notification, null, sessionState.Item4, exception, sessionState.Item1.Configuration.IsDebugMode ); } } previous.Dispose(); return; } switch (previous.Status) { case TaskStatus.Canceled: { context.Serialize <object>(null, new RpcErrorMessage(RpcError.TimeoutError, "Server task exceeds execution timeout.", null), null); break; } case TaskStatus.Faulted: { context.Serialize <object>(null, new RpcErrorMessage(RpcError.RemoteRuntimeError, "Dispatcher throws exception.", previous.Exception.ToString()), null); break; } } previous.Dispose(); transport.Send(context); }
private void ClientConnected(string clientId) { _replicator.SendState(str => _transport.Send(clientId, str)); ClientsCount++; }