RemoteAgent.CreatePacketStream, méthode

Mise à jour : novembre 2007

Crée une connexion à l'agent Smart Device pour échanger des données.

Espace de noms :  Microsoft.SmartDevice.Connectivity
Assembly :  Microsoft.SmartDevice.Connectivity (dans Microsoft.SmartDevice.Connectivity.dll)

Syntaxe

Public Function CreatePacketStream ( _
    serviceId As ObjectId _
) As DevicePacketStream

Dim instance As RemoteAgent
Dim serviceId As ObjectId
Dim returnValue As DevicePacketStream

returnValue = instance.CreatePacketStream(serviceId)
public DevicePacketStream CreatePacketStream(
    ObjectId serviceId
)
public:
DevicePacketStream^ CreatePacketStream(
    ObjectId^ serviceId
)
public function CreatePacketStream(
    serviceId : ObjectId
) : DevicePacketStream

Paramètres

Valeur de retour

Type : Microsoft.SmartDevice.Connectivity.DevicePacketStream

Un objet DevicePacketStream qui peut transférer des données entre l'agent Smart Device et l'ordinateur de développement.

Exceptions

Exception Condition
SmartDeviceException

Se produit si une exception COM est levée par les composants COM sous-jacents.

DeviceNotConnectedException

Se produit si un appareil n'est pas connecté.

Notes

Il doit y avoir un agent côté appareil de type Smart Device prêt à accepter une connexion sur le même ID de service. L'agent côté appareil de type Smart Device est déployé lorsque Start est appelé. Un agent Smart Device peut accepter plusieurs connexions de flux de données sur des ID de service différents.

Exemples

' Open communication channel with device agent.
Dim ps As DevicePacketStream = ra.CreatePacketStream( _
    New ObjectId("2FAD740C-B5D3-4ad0-BE23-5682503584BF"))

' Create and write a packet of data.
Dim packet As Packet
packet = New Packet()
Dim i As Integer
For i = 0 To 3
    packet.WriteInt32(i)
Next i
packet.WriteString("Hello Smart Device")
ps.Write(packet)
// Open communication channel with device agent.
DevicePacketStream ps = ra.CreatePacketStream(
    new ObjectId("2FAD740C-B5D3-4ad0-BE23-5682503584BF"));

// Create and write a packet of data.
Packet packet;
packet = new Packet();
for (int i = 0; i < 4; i ++) packet.WriteInt32(i);
packet.WriteString("Hello Smart Device");
ps.Write(packet);

Autorisations

Voir aussi

Référence

RemoteAgent, classe

Membres RemoteAgent

Microsoft.SmartDevice.Connectivity, espace de noms