本文整理汇总了C#中BusAttachment类的典型用法代码示例。如果您正苦于以下问题:C# BusAttachment类的具体用法?C# BusAttachment怎么用?C# BusAttachment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BusAttachment类属于命名空间,在下文中一共展示了BusAttachment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChatSessionObject
/// <summary>
/// Initializes a new instance of the ChatSessionObject class.
/// </summary>
/// <param name="bus">The BusAttachment to be associated with.</param>
/// <param name="path">The path for the BusObject.</param>
/// <param name="host">The instance of the MainPage which handles the UI for this
/// application.</param>
public ChatSessionObject(BusAttachment bus, string path, MainPage host)
{
try
{
this.hostPage = host;
this.busObject = new BusObject(bus, path, false);
/* Add the interface to this object */
InterfaceDescription[] ifaceArr = new InterfaceDescription[1];
bus.CreateInterface(ChatServiceInterfaceName, ifaceArr, false);
ifaceArr[0].AddSignal("Chat", "s", "str", 0, string.Empty);
ifaceArr[0].Activate();
InterfaceDescription chatIfc = bus.GetInterface(ChatServiceInterfaceName);
this.busObject.AddInterface(chatIfc);
this.chatSignalReceiver = new MessageReceiver(bus);
this.chatSignalReceiver.SignalHandler += new MessageReceiverSignalHandler(this.ChatSignalHandler);
this.chatSignalMember = chatIfc.GetMember("Chat");
bus.RegisterSignalHandler(this.chatSignalReceiver, this.chatSignalMember, path);
}
catch (System.Exception ex)
{
QStatus errCode = AllJoyn.AllJoynException.GetErrorCode(ex.HResult);
string errMsg = AllJoyn.AllJoynException.GetErrorMessage(ex.HResult);
this.hostPage.DisplayStatus("Create ChatSessionObject Error : " + errMsg);
}
}
示例2: SignalConsumerBusListener
/// <summary>
/// Initializes a new instance of the <see cref="SignalConsumerBusListener" /> class
/// </summary>
/// <param name="bus">object responsible for connecting to and optionally managing a message
/// bus</param>
/// <param name="foundNameEvent">event to set when the well-known name being queried
/// is found</param>
public SignalConsumerBusListener(BusAttachment bus, AutoResetEvent foundNameEvent)
{
SessionidList = new List<uint>();
this.busAtt = bus;
this.foundName = foundNameEvent;
this.busListener = new BusListener(bus);
this.busListener.BusDisconnected += new BusListenerBusDisconnectedHandler(this.BusListenerBusDisconnected);
this.busListener.BusStopping += new BusListenerBusStoppingHandler(this.BusListenerBusStopping);
this.busListener.FoundAdvertisedName += new BusListenerFoundAdvertisedNameHandler(this.BusListenerFoundAdvertisedName);
this.busListener.ListenerRegistered += new BusListenerListenerRegisteredHandler(this.BusListenerListenerRegistered);
this.busListener.ListenerUnregistered += new BusListenerListenerUnregisteredHandler(this.BusListenerListenerUnregistered);
this.busListener.LostAdvertisedName += new BusListenerLostAdvertisedNameHandler(this.BusListenerLostAdvertisedName);
this.busListener.NameOwnerChanged += new BusListenerNameOwnerChangedHandler(this.BusListenerNameOwnerChanged);
this.sessionListener = new SessionListener(this.busAtt);
this.sessionListener.SessionLost += new SessionListenerSessionLostHandler(this.SessionListenerSessionLost);
this.sessionListener.SessionMemberAdded += new SessionListenerSessionMemberAddedHandler(this.SessionListenerSessionMemberAdded);
this.sessionListener.SessionMemberRemoved += new SessionListenerSessionMemberRemovedHandler(this.SessionListenerSessionMemberRemoved);
MessageReceiver signalReceiver = new MessageReceiver(bus);
signalReceiver.SignalHandler += this.NameChangedSignalHandler;
InterfaceDescription interfaceDescription2 = bus.GetInterface(SignalConsumerGlobals.InterfaceName);
InterfaceMember signalMember = interfaceDescription2.GetSignal("nameChanged");
bus.RegisterSignalHandler(signalReceiver, signalMember, string.Empty);
}
示例3: ClientBusListener
/// <summary>
/// Initializes a new instance of the <see cref="ClientBusListener" /> class.
/// </summary>
/// <param name="busAtt">object responsible for connecting to and optionally managing a message
/// bus.</param>
/// <param name="op">Stress Operation using this class as listener object</param>
/// <param name="foundNameEvent">Event to set when the first service is discovered</param>
public ClientBusListener(BusAttachment busAtt, StressOperation op, AutoResetEvent foundNameEvent)
{
this.stressOp = op;
this.mutex = new Mutex();
this.foundAvertisedName = false;
this.foundName = foundNameEvent;
// Create Bus Listener and register signal handlers
this.busListener = new BusListener(busAtt);
this.busListener.BusDisconnected += new BusListenerBusDisconnectedHandler(this.BusListenerBusDisconnected);
this.busListener.BusStopping += new BusListenerBusStoppingHandler(this.BusListenerBusStopping);
this.busListener.FoundAdvertisedName += new BusListenerFoundAdvertisedNameHandler(this.BusListenerFoundAdvertisedName);
this.busListener.ListenerRegistered += new BusListenerListenerRegisteredHandler(this.BusListenerListenerRegistered);
this.busListener.ListenerUnregistered += new BusListenerListenerUnregisteredHandler(this.BusListenerListenerUnregistered);
this.busListener.LostAdvertisedName += new BusListenerLostAdvertisedNameHandler(this.BusListenerLostAdvertisedName);
this.busListener.NameOwnerChanged += new BusListenerNameOwnerChangedHandler(this.BusListenerNameOwnerChanged);
// Create Session Listener and register signal handlers
this.sessionListener = new SessionListener(busAtt);
this.sessionListener.SessionLost += new SessionListenerSessionLostHandler(this.SessionListenerSessionLost);
this.sessionListener.SessionMemberAdded += new SessionListenerSessionMemberAddedHandler(this.SessionListenerSessionMemberAdded);
this.sessionListener.SessionMemberRemoved += new SessionListenerSessionMemberRemovedHandler(this.SessionListenerSessionMemberRemoved);
busAtt.RegisterBusListener(this.busListener);
}
示例4: MyBusListener
/// <summary>
/// Initializes a new instance of the <see cref="MyBusListener" /> class.
/// </summary>
/// <param name="busAtt">object responsible for connecting to and optionally managing a message
/// bus.</param>
/// <param name="ops">Session operations object for this application</param>
public MyBusListener(BusAttachment busAtt, SessionOperations ops)
{
this.sessionOps = ops;
// Create Bus Listener and register signal handlers
this.busListener = new BusListener(busAtt);
this.busListener.BusDisconnected += new BusListenerBusDisconnectedHandler(this.BusListenerBusDisconnected);
this.busListener.BusStopping += new BusListenerBusStoppingHandler(this.BusListenerBusStopping);
this.busListener.FoundAdvertisedName += new BusListenerFoundAdvertisedNameHandler(this.BusListenerFoundAdvertisedName);
this.busListener.ListenerRegistered += new BusListenerListenerRegisteredHandler(this.BusListenerListenerRegistered);
this.busListener.ListenerUnregistered += new BusListenerListenerUnregisteredHandler(this.BusListenerListenerUnregistered);
this.busListener.LostAdvertisedName += new BusListenerLostAdvertisedNameHandler(this.BusListenerLostAdvertisedName);
this.busListener.NameOwnerChanged += new BusListenerNameOwnerChangedHandler(this.BusListenerNameOwnerChanged);
// Create Session Listener and register signal handlers
this.sessionListener = new SessionListener(busAtt);
this.sessionListener.SessionLost += new SessionListenerSessionLostHandler(this.SessionListenerSessionLost);
this.sessionListener.SessionMemberAdded += new SessionListenerSessionMemberAddedHandler(this.SessionListenerSessionMemberAdded);
this.sessionListener.SessionMemberRemoved += new SessionListenerSessionMemberRemovedHandler(this.SessionListenerSessionMemberRemoved);
// Create Session Port Listener and register signal handlers
this.sessionPortListener = new SessionPortListener(busAtt);
this.sessionPortListener.AcceptSessionJoiner += new SessionPortListenerAcceptSessionJoinerHandler(this.SessionPortListenerAcceptSessionJoiner);
this.sessionPortListener.SessionJoined += new SessionPortListenerSessionJoinedHandler(this.SessionPortListenerSessionJoined);
busAtt.RegisterBusListener(this.busListener);
}
示例5: AddInterfaceTest
public void AddInterfaceTest()
{
BusAttachment bus = new BusAttachment("addinterface", true, 4);
bus.CreateInterfacesFromXml(signalIntf);
bus.CreateInterfacesFromXml(methodIntf);
bus.CreateInterfacesFromXml(propertyIntf);
bus.CreateInterfacesFromXml(mixedIntf);
bus.CreateInterfacesFromXml(emptyIntf);
InterfaceDescription[] annIntf = new InterfaceDescription[1];
bus.CreateInterface("org.alljoyn.Annotated", annIntf, false);
annIntf[0].AddMethod("method", "ss", "s", "in1,in2,out1", (byte)0, "");
annIntf[0].AddProperty("property", "s", (byte)PropAccessType.PROP_ACCESS_RW);
annIntf[0].AddSignal("signal", "suy", "str,uint,byte", (byte)0, "");
annIntf[0].AddAnnotation("org.freedesktop.DBus.Deprecated", "false");
annIntf[0].AddMemberAnnotation("method", "org.freedesktop.DBus.Method.NoReply", "true");
annIntf[0].AddPropertyAnnotation("property", "org.freedesktop.DBus.Property.EmitsChangedSignal", "true");
annIntf[0].Activate();
BusObject busObj = new BusObject(bus, "/addinterfaces", false);
busObj.AddInterface(bus.GetInterface("org.alljoyn.Signals"));
busObj.AddInterface(bus.GetInterface("org.alljoyn.Methods"));
busObj.AddInterface(bus.GetInterface("org.alljoyn.Properties"));
busObj.AddInterface(bus.GetInterface("org.alljoyn.Empty"));
busObj.AddInterface(bus.GetInterface("org.alljoyn.Annotated"));
}
示例6: FileTransferBusObject
/// <summary>
/// Initializes a new instance of the <see cref="FileTransferBusObject" /> class.
/// </summary>
/// <param name="busAtt">Object responsible for connecting to and optionally managing a
/// message bus.</param>
public FileTransferBusObject(BusAttachment busAtt)
{
this.Bus = busAtt;
this.Folder = null;
this.lastIndex = 0;
this.SessionId = 0;
if (null == this.Bus)
{
App.OutputLine("Unexpected null object in parameters to FileTransferBusObject constructor.");
}
}
示例7: SecureBusObject
/// <summary>
/// Initializes a new instance of the <see cref="SecureBusObject" /> class.
/// </summary>
/// <param name="busAtt">Object responsible for connecting to and optionally managing a
/// message bus.</param>
/// <param name="iface">The interface used by the service that is implemented by this
/// class.</param>
public SecureBusObject(BusAttachment busAtt, InterfaceDescription[] iface)
{
this.BusObject = new BusObject(busAtt, App.ServicePath, false);
this.BusObject.AddInterface(iface[0]);
InterfaceMember pingMember = iface[0].GetMember("Ping");
MessageReceiver pingReceiver = new MessageReceiver(busAtt);
pingReceiver.MethodHandler += new MessageReceiverMethodHandler(this.PingMethodHandler);
BusObject.AddMethodHandler(pingMember, pingReceiver);
busAtt.RegisterBusObject(this.BusObject);
}
示例8: AddMatchBusObj
public AddMatchBusObj(BusAttachment bus)
{
this.busObj = new BusObject(bus, "/test", false);
InterfaceDescription[] intf = new InterfaceDescription[1];
bus.CreateInterface("org.alljoyn.addmatchtest", intf, false);
intf[0].AddSignal("testSig", "s", "str", (byte)0, "");
intf[0].Activate();
this.busObj.AddInterface(intf[0]);
MessageReceiver receiver = new MessageReceiver(bus);
receiver.SignalHandler += new MessageReceiverSignalHandler(this.SigHandle);
bus.RegisterSignalHandler(receiver, intf[0].GetSignal("testSig"), "");
bus.RegisterBusObject(this.busObj);
}
示例9: SignalServiceBusObject
/// <summary>
/// Initializes a new instance of the <see cref="SignalServiceBusObject" /> class
/// </summary>
/// <param name="busAtt">object responsible for connecting to and optionally managing a message
/// bus</param>
public SignalServiceBusObject(BusAttachment busAtt)
{
this.BusObject = new BusObject(busAtt, SignalServiceGlobals.ServicePath, false);
this.name = string.Empty;
InterfaceDescription[] interfaceDescription = new InterfaceDescription[1];
busAtt.CreateInterface(SignalServiceGlobals.InterfaceName, interfaceDescription, false);
interfaceDescription[0].AddSignal("nameChanged", "s", "newName", (byte)0, string.Empty);
interfaceDescription[0].AddProperty("name", "s", (byte)PropAccessType.PROP_ACCESS_RW);
interfaceDescription[0].Activate();
this.BusObject.AddInterface(interfaceDescription[0]);
App.OutputLine("Interface created and added to the Bus Object.");
this.signalMember = interfaceDescription[0].GetSignal("nameChanged");
this.BusObject.Set += this.SetHandler;
busAtt.RegisterBusObject(this.BusObject);
App.OutputLine("Bus Object and property set handlers Registered.");
}
示例10: NameChangeBusListener
/// <summary>
/// Initializes a new instance of the <see cref="NameChangeBusListener" /> class
/// </summary>
/// <param name="bus">object responsible for connecting to and optionally managing a message
/// bus</param>
/// <param name="foundNameEvent">event to set when the well-known name being queried
/// is found</param>
public NameChangeBusListener(BusAttachment bus, AutoResetEvent foundNameEvent)
{
this.busAtt = bus;
this.foundName = foundNameEvent;
this.busListener = new BusListener(this.busAtt);
this.busListener.BusDisconnected += new BusListenerBusDisconnectedHandler(this.BusListenerBusDisconnected);
this.busListener.BusStopping += new BusListenerBusStoppingHandler(this.BusListenerBusStopping);
this.busListener.FoundAdvertisedName += new BusListenerFoundAdvertisedNameHandler(this.BusListenerFoundAdvertisedName);
this.busListener.ListenerRegistered += new BusListenerListenerRegisteredHandler(this.BusListenerListenerRegistered);
this.busListener.ListenerUnregistered += new BusListenerListenerUnregisteredHandler(this.BusListenerListenerUnregistered);
this.busListener.LostAdvertisedName += new BusListenerLostAdvertisedNameHandler(this.BusListenerLostAdvertisedName);
this.busListener.NameOwnerChanged += new BusListenerNameOwnerChangedHandler(this.BusListenerNameOwnerChanged);
this.sessionListener = new SessionListener(this.busAtt);
this.sessionListener.SessionLost += new SessionListenerSessionLostHandler(this.SessionListenerSessionLost);
this.sessionListener.SessionMemberAdded += new SessionListenerSessionMemberAddedHandler(this.SessionListenerSessionMemberAdded);
this.sessionListener.SessionMemberRemoved += new SessionListenerSessionMemberRemovedHandler(this.SessionListenerSessionMemberRemoved);
}
示例11: AudioStream
public AudioStream(BusAttachment bus, string name, MP3Reader mp3Reader, UInt32 jitter, UInt32 prefill)
{
_mediaStream = new MediaStream(bus, name, mp3Reader.GetDescription());
_mediaPacer = new MediaPacer(mp3Reader.GetDescription(), jitter, 0);
_mp3Reader = mp3Reader;
_prefill = prefill;
_mediaStream.OnOpen += OnOpen;
_mediaStream.OnClose += OnClose;
_mediaStream.OnPlay += OnPlay;
_mediaStream.OnPause += OnPause;
_mediaStream.OnSeekRelative += OnSeekRelative;
_mediaStream.OnSeekAbsolute += OnSeekAbsolute;
_mediaPacer.JitterMiss += JitterMiss;
_mediaPacer.RequestFrames += RequestFrames;
_buffer = new byte[_frameReadLength * _mp3Reader.FrameLen];
}
示例12: BasicClientBusListener
/// <summary>
/// Initializes a new instance of the <see cref="BasicClientBusListener" /> class
/// </summary>
/// <param name="bus">object responsible for connecting to and optionally managing a message
/// bus</param>
/// <param name="foundNameEvent">event to set when the well-known name being queried
/// is found</param>
public BasicClientBusListener(BusAttachment bus, AutoResetEvent foundNameEvent)
{
SessionidList = new List<uint>();
busAtt = bus;
foundName = foundNameEvent;
busListener = new BusListener(bus);
busListener.BusDisconnected += new BusListenerBusDisconnectedHandler(BusListenerBusDisconnected);
busListener.BusStopping += new BusListenerBusStoppingHandler(BusListenerBusStopping);
busListener.FoundAdvertisedName += new BusListenerFoundAdvertisedNameHandler(BusListenerFoundAdvertisedName);
busListener.ListenerRegistered += new BusListenerListenerRegisteredHandler(BusListenerListenerRegistered);
busListener.ListenerUnregistered += new BusListenerListenerUnregisteredHandler(BusListenerListenerUnregistered);
busListener.LostAdvertisedName += new BusListenerLostAdvertisedNameHandler(BusListenerLostAdvertisedName);
busListener.NameOwnerChanged += new BusListenerNameOwnerChangedHandler(BusListenerNameOwnerChanged);
sessionListener = new SessionListener(bus);
sessionListener.SessionLost += new SessionListenerSessionLostHandler(SessionListenerSessionLost);
sessionListener.SessionMemberAdded += new SessionListenerSessionMemberAddedHandler(SessionListenerSessionMemberAdded);
sessionListener.SessionMemberRemoved += new SessionListenerSessionMemberRemovedHandler(SessionListenerSessionMemberRemoved);
}
示例13: ServiceBusObject
/// <summary>
/// Initializes a new instance of the <see cref="ServiceBusObject"/> class.
/// </summary>
/// <param name="busAtt">Message bus for the stress operation using this</param>
/// <param name="op">Stress operation using this bus object</param>
public ServiceBusObject(BusAttachment busAtt, StressOperation op)
{
this.stressOp = op;
this.busObject = new BusObject(busAtt, ServicePath, false);
// Implement the 'cat' interface
InterfaceDescription[] intfDescription = new InterfaceDescription[1];
busAtt.CreateInterface(InterfaceName, intfDescription, false);
intfDescription[0].AddMethod("cat", "ss", "s", "inStr1,inStr2,outStr", (byte)0, string.Empty);
intfDescription[0].Activate();
this.busObject.AddInterface(intfDescription[0]);
// Register 'cat' method handler
InterfaceMember catMethod = intfDescription[0].GetMethod("cat");
MessageReceiver catReceiver = new MessageReceiver(busAtt);
catReceiver.MethodHandler += new MessageReceiverMethodHandler(this.Cat);
this.busObject.AddMethodHandler(catMethod, catReceiver);
busAtt.RegisterBusObject(this.busObject);
}
示例14: BusObject
public BusObject(BusAttachment bus, string path, bool isPlaceholder)
{
// Can't let the GC free these delegates so they must be members
_propertyGet = new InternalPropertyGetEventHandler(this._PropertyGet);
_propertySet = new InternalPropertySetEventHandler(this._PropertySet);
_objectRegistered = new InternalObjectRegisteredEventHandler(this._ObjectRegistered);
_objectUnregistered = new InternalObjectUnregisteredEventHandler(this._ObjectUnregistered);
// Ref holder for method handler internal delegates
_methodHandlerDelegateRefHolder = new List<InternalMethodHandler>();
BusObjectCallbacks callbacks;
callbacks.property_get = Marshal.GetFunctionPointerForDelegate(_propertyGet);
callbacks.property_set = Marshal.GetFunctionPointerForDelegate(_propertySet);
callbacks.object_registered = Marshal.GetFunctionPointerForDelegate(_objectRegistered);
callbacks.object_unregistered = Marshal.GetFunctionPointerForDelegate(_objectUnregistered);
GCHandle gch = GCHandle.Alloc(callbacks, GCHandleType.Pinned);
_busObject = alljoyn_busobject_create(bus.UnmanagedPtr, path, isPlaceholder ? 1 : 0, gch.AddrOfPinnedObject(), IntPtr.Zero);
gch.Free();
}
示例15: MyBusObject
/// <summary>
/// Initializes a new instance of the <see cref="MyBusObject"/> class
/// </summary>
/// <param name="busAtt">Message bus for the sessions app</param>
/// <param name="ops">Session Operations object for this application</param>
public MyBusObject(BusAttachment busAtt, SessionOperations ops)
{
this.busObject = new BusObject(busAtt, BusObjectPath, false);
this.sessionOps = ops;
this.ChatEcho = true;
// Implement the 'Chat' interface
InterfaceDescription[] intfDescription = new InterfaceDescription[1];
busAtt.CreateInterface(SessionInterfaceName, intfDescription, false);
intfDescription[0].AddSignal("Chat", "s", "str", (byte)0, string.Empty);
intfDescription[0].Activate();
this.chatSignal = intfDescription[0].GetSignal("Chat");
this.busObject.AddInterface(intfDescription[0]);
// Register chat signal handler
MessageReceiver signalReceiver = new MessageReceiver(busAtt);
signalReceiver.SignalHandler += new MessageReceiverSignalHandler(this.ChatSignalHandler);
busAtt.RegisterSignalHandler(signalReceiver, this.chatSignal, string.Empty);
busAtt.RegisterBusObject(this.busObject);
}