public Subscriber DeclareSubscriber(ResKey reskey, SubInfo subInfo, SubscriberCallback callback) { // convert the C# user callback as IntPtr to be passed as "arg" to zn_declare_subscriber() // and received back in each call to SubscriberCallbackNativeImpl IntPtr callbackPtr = Marshal.GetFunctionPointerForDelegate(callback); var nativeSubscriber = ZnDeclareSubscriber(this._nativePtr, reskey._key, subInfo._subInfo, SubscriberCallbackNativeImpl, callbackPtr); return(new Subscriber(nativeSubscriber)); }
public Subscriber DeclareSubscriber(ResKey reskey, SubInfo subInfo, SubscriberCallback callback) { Int32 subscriberHandle = Interlocked.Increment(ref _subscriberCounter); var nativeSubscriber = ZnDeclareSubscriber(_nativePtr, reskey._key, subInfo._subInfo, _subscriberCallbackNative, new IntPtr(subscriberHandle)); var subscriber = new Subscriber(this, subscriberHandle, nativeSubscriber, callback); Subscribers[subscriberHandle] = subscriber; return(subscriber); }
private Teleop(Dictionary <string, string> zenohConf, String cmdTopic, String outTopic, double linearScale, double angularScale) { // initiate logging Zenoh.Zenoh.InitLogger(); Console.WriteLine("Openning session..."); _session = Zenoh.Net.Session.Open(zenohConf); Console.WriteLine("Subscribing on {0}", outTopic); _subscriber = _session.DeclareSubscriber( Zenoh.Net.ResKey.RName(outTopic), new Zenoh.Net.SubInfo(), OutCallback); Console.WriteLine("Publishing on {0}", cmdTopic); _cmdKey = Zenoh.Net.ResKey.RName(cmdTopic); _linearScale = linearScale; _angularScale = angularScale; }
public ulong DeclareResource(ResKey reskey) { return(ZnDeclareResource(this._nativePtr, reskey._key)); }