public static void Main() { // Report the initial status. Console.WriteLine("Starting client."); // Register the TCP channel. ChannelServices.RegisterChannel(new TcpChannel()); //<snippet1> // Create a url attribute object. UrlAttribute attribute = new UrlAttribute("tcp://localhost:1234/RemoteApp"); Console.WriteLine("UrlAttribute value: {0}", attribute.UrlValue); //</snippet1> object[] activationAttributes = new object[] { attribute }; // Register the client for the remote object. RemotingConfiguration.RegisterActivatedClientType( typeof(RemoteObject), "tcp://localhost:1234/RemoteApp"); // Activate the remote object. Console.WriteLine("Activating remote object."); RemoteObject obj = (RemoteObject)Activator.CreateInstance( typeof(RemoteObject), null, activationAttributes); // Invoke a method on the remote object. Console.WriteLine("Invoking Hello() on remote object."); obj.Hello(); // Inform the user that the program is exiting. Console.WriteLine("The client is exiting."); }
public static void Main(string[] args) { // Create the channel. HttpClientChannel clientChannel = null; string overload = args[0]; if (overload == "1") { clientChannel = Ctor1(); } else if (overload == "2") { clientChannel = Ctor2(); } else { throw new Exception("Argument " + args[0] + "was invalid."); } // Register the channel and the client. Register(clientChannel); // Create an instance of the remote object. RemoteObject service = new RemoteObject(); // Invoke a method on the remote object. InvokeRemoteObject(service); }
static void Main(string[] args) { var channel = new IpcChannel(); ChannelServices.RegisterChannel(channel, false); var remoteType = new WellKnownClientTypeEntry( typeof(RemoteObject), "ipc://localhost:9090/RemoteObject.rem"); RemotingConfiguration.RegisterWellKnownClientType(remoteType); // Create a message sink string objectUri; var messageSink = channel.CreateMessageSink( "ipc://localhost:9090/RemoteObject.rem", null, out objectUri); Console.WriteLine("The URI of the message sink is {0}.", objectUri); if (messageSink != null) { Console.WriteLine("The type of the message sink is {0}.", messageSink.GetType().ToString()); } // Create an instance of the remote object. var service = new RemoteObject(); // Invoke a method on the remote object. Console.WriteLine("The client is invoking the remote object."); Console.WriteLine("The remote object has been called {0} times.", service.GetCount()); Console.ReadKey(); }
public DirectoryInfo GetDirectory(string fullName) { DirectoryInfo directory = Execute(() => RemoteObject.GetDirectory(fullName)); directory.ChangeFileSystemAccessor(this); return(directory); }
private static object ValueFromUnserializableValue(RemoteObject remoteObject, string unserializableValue) { if (remoteObject.Type == RemoteObjectType.Bigint && decimal.TryParse(remoteObject.UnserializableValue.Replace("n", ""), out var decimalValue)) { return(new BigInteger(decimalValue)); } switch (unserializableValue) { case "-0": return(-0); case "NaN": return(double.NaN); case "Infinity": return(double.PositiveInfinity); case "-Infinity": return(double.NegativeInfinity); default: throw new Exception("Unsupported unserializable value: " + unserializableValue); } }
internal ElementHandle( ExecutionContext context, CDPSession client, RemoteObject remoteObject) : base(context, client, remoteObject) { }
internal JSHandle(ExecutionContext context, CDPSession client, RemoteObject remoteObject) { ExecutionContext = context; Client = client; Logger = Client.Connection.LoggerFactory.CreateLogger(GetType()); RemoteObject = remoteObject; }
public FileInfo GetFile(string fullName) { FileInfo file = Execute(() => RemoteObject.GetFile(fullName)); file.ChangeFileSystemAccessor(this); return(file); }
static void InvokeRemoteObject(RemoteObject service) { // Invoke a method on the remote object. Console.WriteLine("The client is invoking the remote object."); Console.WriteLine("The remote object has been called {0} times.", service.GetCount()); }
static void Main(string[] args) { ChannelServices.RegisterChannel(new TcpClientChannel(), false); RemoteObject remoteobj = (RemoteObject)Activator.GetObject(typeof(RemoteObject), "tcp://localhost:6666/RemoteObject"); Console.WriteLine($"1 + 2 = {remoteobj.Sum(1, 2)}"); Console.ReadLine(); }
static void SendMessage(RemoteObject obj) { while (true) { string str = Console.ReadLine(); obj.AddMessage(str); } }
/// <summary> /// Завершение сессии в диспетчере устройств /// </summary> public void Logout() { if (Logged) { RemoteObject.Logout(_sessionId); _sessionId = string.Empty; } }
private void InitializeCollection() { lock (_dictionaryByUid) { _collectionUpdatedSubscriber.Subscribe(); UpdateCollection(RemoteObject.ToList()); } }
internal void TryAnnotateWithClient(RemoteObject o) { if (o == null) { return; } o.Client = Client; }
public SubProgram() { chan = new TcpChannel(); ChannelServices.RegisterChannel(chan, false); obj = (RemoteObject)Activator.GetObject(typeof(SearchClasses.RemoteObject), "tcp://localhost:8080/Search"); obj.Create(); obj.GenerateTasks(); }
public IsolatedJob(Type jobType) { if (jobType == null) throw new ArgumentNullException("jobType"); this.JobType = jobType; var path = Path.GetDirectoryName(this.JobType.Assembly.Location); this.IDL = new IsolateDomainLoader(path, string.Format("{0}.dll.config", this.JobType.Assembly.GetName().Name)); this.Obj = this.IDL.GetObject(this.JobType.Assembly.Location, this.JobType.FullName); }
public static void Main(string[] args) { ChannelServices.RegisterChannel(new TcpClientChannel(), true); RemoteObject remoteobj = (RemoteObject)Activator.GetObject(typeof(RemoteObject), "tcp://localhost:6666/RemoteObject"); Console.WriteLine("1 + 2 = " + remoteobj.sum(1, 2).ToString()); Console.ReadLine(); }
public Task <RemoteObject> CallMethodWithFuture( RemoteObject @this, string methodName, IFuture future, params object[] arguments ) { var fn = "function () { return this." + methodName + ".apply(this, arguments); }"; return(CallFunctionOnWithFuture(@this, fn, future, arguments)); }
internal static object ValueFromRemoteObject <T>(RemoteObject remoteObject) { var unserializableValue = remoteObject.UnserializableValue; if (unserializableValue != null) { switch (unserializableValue) { case "-0": return(-0); case "NaN": return(double.NaN); case "Infinity": return(double.PositiveInfinity); case "-Infinity": return(double.NegativeInfinity); default: throw new Exception("Unsupported unserializable value: " + unserializableValue); } } var value = remoteObject.Value; if (value == null) { return(null); } // https://chromedevtools.github.io/devtools-protocol/tot/Runtime#type-RemoteObject var objectType = remoteObject.Type; switch (objectType) { case RemoteObjectType.Object: return(value.ToObject <T>(true)); case RemoteObjectType.Undefined: return(null); case RemoteObjectType.Number: return(value.Value <T>()); case RemoteObjectType.Boolean: return(value.Value <bool>()); case RemoteObjectType.Bigint: return(value.Value <double>()); default: // string, symbol, function return(value.ToObject <T>()); } }
private T ExtractResult <T>(ExceptionDetails exceptionDetails, RemoteObject remoteObject, bool returnByValue, ExecutionContext context) { CheckException(exceptionDetails); if (returnByValue) { return(DeserializeValue <T>(remoteObject)); } return((T)context.CreateHandle(remoteObject)); }
internal static DynamicObjectResult Get(RemoteObject value, ChromeSession session) { if (value.Type == "undefined") { return(null); } return(new DynamicObjectResult(value.ObjectId, session)); }
public override void handle(LocalDevice localDevice, Address from, OctetString linkService) { // TODO RemoteDevice d = localDevice.getRemoteDeviceCreate(deviceIdentifier.getInstanceNumber(), from, linkService); RemoteObject o = new RemoteObject(objectIdentifier); o.ObjectName = objectName.ToString(); // TODO d.setObject(o); // TODO localDevice.getEventHandler().fireIHaveReceived(d, o); }
public async Task <T> EvaluateAsync <T>(ExecutionContext context, bool returnByValue, string script, object[] args) { string suffix = $"//# sourceURL={EvaluationScriptUrl}"; RemoteObject remoteObject = null; if (script.IsJavascriptFunction()) { RuntimeCallFunctionOnResponse result = null; try { result = await _client.SendAsync(new RuntimeCallFunctionOnRequest { FunctionDeclaration = $"{script}\n{suffix}\n", ExecutionContextId = ContextId, Arguments = args.Select(a => FormatArgument(a, context)).ToArray(), ReturnByValue = returnByValue, AwaitPromise = true, UserGesture = true, }).ConfigureAwait(false); } catch (Exception ex) { result = RewriteError(ex); } if (result.ExceptionDetails != null) { throw new PlaywrightSharpException($"Evaluation failed: {result.ExceptionDetails.ToExceptionMessage()}"); } remoteObject = result.Result; } else { string expressionWithSourceUrl = _sourceUrlRegex.IsMatch(script) ? script : script + '\n' + suffix; var result = await _client.SendAsync(new RuntimeEvaluateRequest { Expression = expressionWithSourceUrl, ContextId = ContextId, ReturnByValue = returnByValue, AwaitPromise = true, UserGesture = true, }).ConfigureAwait(false); if (result.ExceptionDetails != null) { throw new PlaywrightSharpException($"Evaluation failed: {result.ExceptionDetails.ToExceptionMessage()}"); } remoteObject = result.Result; } return((T)(returnByValue ? GetValueFromRemoteObject <T>(remoteObject) : context.CreateHandle(remoteObject))); }
public static void Main(string[] args) { // Create the channel. HttpClientChannel clientChannel = new HttpClientChannel(); // Register the channel. ChannelServices.RegisterChannel(clientChannel); // Register as client for remote object. WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry(typeof(RemoteObject), "http://localhost:9090/RemoteObject.rem"); RemotingConfiguration.RegisterWellKnownClientType(remoteType); // Create a message sink. string objectUri; System.Runtime.Remoting.Messaging.IMessageSink messageSink = clientChannel.CreateMessageSink( "http://localhost:9090/RemoteObject.rem", null, out objectUri); Console.WriteLine( "The URI of the message sink is {0}.", objectUri); if (messageSink != null) { Console.WriteLine("The type of the message sink is {0}.", messageSink.GetType().ToString()); } // Display the channel's properties using Keys and Item. foreach (string key in clientChannel.Keys) { Console.WriteLine( "clientChannel[{0}] = <{1}>", key, clientChannel[key]); } // Parse the channel's URI. string objectUrl = "http://localhost:9090/RemoteObject.rem"; string channelUri = clientChannel.Parse(objectUrl, out objectUri); Console.WriteLine("The object URL is {0}.", objectUrl); Console.WriteLine("The object URI is {0}.", objectUri); Console.WriteLine("The channel URI is {0}.", channelUri); // Create an instance of the remote object. RemoteObject service = new RemoteObject(); // Invoke a method on the remote object. Console.WriteLine("The client is invoking the remote object."); Console.WriteLine("The remote object has been called {0} times.", service.GetCount()); }
internal ElementHandle( ExecutionContext context, CDPSession client, RemoteObject remoteObject, Page page, FrameManager frameManager) : base(context, client, remoteObject) { Page = page; _frameManager = frameManager; _logger = client.LoggerFactory.CreateLogger <ElementHandle>(); }
/* Simple method used to create a placeholder */ private void GetInput() { if (fbxObj == null) { if (Input.GetKeyDown(KeyCode.P) && isServer) { fbxObj = new RemoteObject("fbxObj"); RpcCreateFbxObj(fbxObj.path); } } }
public bool IsRegistered(Type type) { lock (_registrations) { if (_registrations.ContainsKey(type)) { return(true); } } return(RemoteObject.IsRegistered(type)); }
public static RemoteObject RegisterClient(Type remoteObject, string PIPE_NAME, string OBJECT_NAME) { IpcClientChannel chan = new IpcClientChannel(); ChannelServices.RegisterChannel(chan, false); RemoteObject remoteObjectInstance = (RemoteObject)Activator.GetObject(remoteObject, string.Format("ipc://{0}/{1}", PIPE_NAME, OBJECT_NAME)); return(remoteObjectInstance); }
public void SetOnNewProcessStarted(OnNewProcessStartedDelegate onNewProcessStarted, string value) { this.value = value; OnNewProcessStartedHandler = onNewProcessStarted; if (!isCallBack) { remoteObject = IPCRegistration.RegisterClient(typeof(RemoteObject), CALLBACK_PIPE_NAME, CALLBACK_OBJECT_NAME); remoteObject.isCallBack = true; remoteObject.SetOnNewProcessStarted(onNewProcessStarted, Process.GetCurrentProcess().Id.ToString()); } }
public void InvokeJobStates() { var obj = new RemoteObject("localhost", 48030, "BusinessLogic"); Assert.That(() => obj.Connect(), "Is TRUE!"); var value = obj.Invoke <string>("JobStates"); Assert.IsFalse(string.IsNullOrEmpty(value)); obj.Disconnect(); }
public void AddMonitoredItem() { var obj = new RemoteObject("localhost", 48030, "BusinessLogic"); Assert.That(() => obj.Connect(), "Is TRUE!"); obj.Monitor( "BoState", v => { Logger.Info($"Received value from {obj.Name}.BoState ... '{v}'."); }); obj.Disconnect(); }
public void InvokeNullString() { var obj = new RemoteObject("localhost", 48030, "BusinessLogic"); Assert.That(() => obj.Connect(), "Is TRUE!"); var value = obj.Invoke <string>("GetNullString"); Assert.IsTrue(value == null); obj.Disconnect(); }
private void RpcCreateFbxObj(string path) { fbxObj = new RemoteObject(path); }