Skip to content

Commit

Permalink
Adding tabs throughout API spec for .NET ignatures, moving supported …
Browse files Browse the repository at this point in the history
…platforms and API access content under API
  • Loading branch information
kriswest committed Nov 15, 2023
1 parent 7de2822 commit edd0740
Show file tree
Hide file tree
Showing 11 changed files with 1,230 additions and 123 deletions.
177 changes: 175 additions & 2 deletions docs/api/ref/Channel.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ sidebar_label: Channel
title: Channel
hide_title: true
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# `Channel`

Represents a context channel that applications can join to share context data and provides functions for interacting with it.
Expand All @@ -18,6 +22,9 @@ There are differences in behavior when you interact with a User channel via the

Channels each have a unique identifier, some display metadata and operations for broadcasting context to other applications, or receiving context from other applications.

<Tabs>
<TabItem value="ts" label="TypeScript/JavaScript">

```ts
interface Channel {
// properties
Expand All @@ -38,6 +45,16 @@ interface Channel {
}
```

</TabItem>
<TabItem value="dotnet" label=".NET">

```csharp
TBC
```

</TabItem>
</Tabs>

**See also:**

- [`Context`](Types#context)
Expand All @@ -50,26 +67,65 @@ interface Channel {

### `id`

<Tabs>
<TabItem value="ts" label="TypeScript/JavaScript">

```ts
public readonly id: string;
```

</TabItem>
<TabItem value="dotnet" label=".NET">

```csharp
TBC
```

</TabItem>
</Tabs>

Uniquely identifies the channel. It is either assigned by the desktop agent (User Channel) or defined by an application (App Channel).

### `type`

<Tabs>
<TabItem value="ts" label="TypeScript/JavaScript">

```ts
public readonly type: "user" | "app" | "private";
```

</TabItem>
<TabItem value="dotnet" label=".NET">

```csharp
TBC
```

</TabItem>
</Tabs>

Can be _user_, _app_ or _private_.

### `displayMetadata`

<Tabs>
<TabItem value="ts" label="TypeScript/JavaScript">

```ts
public readonly displayMetadata?: DisplayMetadata;
```

</TabItem>
<TabItem value="dotnet" label=".NET">

```csharp
TBC
```

</TabItem>
</Tabs>

DisplayMetadata can be used to provide display hints for User Channels intended to be visualized and selectable by end users.

**See also:**
Expand All @@ -80,10 +136,23 @@ DisplayMetadata can be used to provide display hints for User Channels intended

### `addContextListener`

<Tabs>
<TabItem value="ts" label="TypeScript/JavaScript">

```ts
public addContextListener(contextType: string | null, handler: ContextHandler): Promise<Listener>;
```

</TabItem>
<TabItem value="dotnet" label=".NET">

```csharp
TBC
```

</TabItem>
</Tabs>

Adds a listener for incoming contexts of the specified _context type_ whenever a broadcast happens on this channel.

If, when this function is called, the channel already contains context that would be passed to the listener it is NOT called or passed this context automatically (this behavior differs from that of the [`fdc3.addContextListener`](DesktopAgent#addcontextlistener) function). Apps wishing to access to the current context of the channel should instead call the [`getCurrentContext(contextType)`](#getcurrentcontext) function.
Expand All @@ -94,6 +163,9 @@ Optional metadata about each context message received, including the app that or

Add a listener for any context that is broadcast on the channel:

<Tabs>
<TabItem value="ts" label="TypeScript/JavaScript">

```ts
const listener = await channel.addContextListener(null, context => {
if (context.type === 'fdc3.contact') {
Expand All @@ -107,8 +179,21 @@ const listener = await channel.addContextListener(null, context => {
listener.unsubscribe();
```

</TabItem>
<TabItem value="dotnet" label=".NET">

```csharp
TBC
```

</TabItem>
</Tabs>

Adding listeners for specific types of context that is broadcast on the channel:

<Tabs>
<TabItem value="ts" label="TypeScript/JavaScript">

```ts
const contactListener = await channel.addContextListener('fdc3.contact', contact => {
// handle the contact
Expand All @@ -123,6 +208,16 @@ contactListener.unsubscribe();
instrumentListener.unsubscribe();
```

</TabItem>
<TabItem value="dotnet" label=".NET">

```csharp
TBC
```

</TabItem>
</Tabs>

**See also:**

- [`Listener`](Types#listener)
Expand All @@ -132,10 +227,23 @@ instrumentListener.unsubscribe();

### `broadcast`

```typescript
<Tabs>
<TabItem value="ts" label="TypeScript/JavaScript">

```ts
public broadcast(context: Context): Promise<void>;
```

</TabItem>
<TabItem value="dotnet" label=".NET">

```csharp
TBC
```

</TabItem>
</Tabs>

Broadcasts a context on the channel. This function can be used without first joining the channel, allowing applications to broadcast on both App Channels and User Channels that they aren't a member of.

If the broadcast is denied by the channel or the channel is not available, the promise will be rejected with an `Error` with a `message` string from the [`ChannelError`](Errors#channelerror) enumeration.
Expand All @@ -148,7 +256,10 @@ If an application attempts to broadcast an invalid context argument the Promise

**Example:**

```javascript
<Tabs>
<TabItem value="ts" label="TypeScript/JavaScript">

```ts
const instrument = {
type: 'fdc3.instrument',
id: {
Expand All @@ -163,6 +274,16 @@ try {
}
```

</TabItem>
<TabItem value="dotnet" label=".NET">

```csharp
TBC
```

</TabItem>
</Tabs>

**See also:**

- [`ChannelError`](Errors#channelerror)
Expand All @@ -171,10 +292,23 @@ try {

### `getCurrentContext`

<Tabs>
<TabItem value="ts" label="TypeScript/JavaScript">

```ts
public getCurrentContext(contextType?: string): Promise<Context|null>;
```

</TabItem>
<TabItem value="dotnet" label=".NET">

```csharp
TBC
```

</TabItem>
</Tabs>

When a _context type_ is provided, the most recent context matching the type will be returned, or `null` if no matching context is found.

If no _context type_ is provided, the most recent context that was broadcast on the channel - regardless of type - will be returned. If no context has been set on the channel, it will return `null`.
Expand All @@ -187,6 +321,9 @@ If getting the current context fails, the promise will be rejected with an `Erro

Without specifying a context type:

<Tabs>
<TabItem value="ts" label="TypeScript/JavaScript">

```ts
try {
const context = await channel.getCurrentContext();
Expand All @@ -195,8 +332,21 @@ try {
}
```

</TabItem>
<TabItem value="dotnet" label=".NET">

```csharp
TBC
```

</TabItem>
</Tabs>

Specifying a context type:

<Tabs>
<TabItem value="ts" label="TypeScript/JavaScript">

```ts
try {
const contact = await channel.getCurrentContext('fdc3.contact');
Expand All @@ -205,6 +355,16 @@ try {
}
```

</TabItem>
<TabItem value="dotnet" label=".NET">

```csharp
TBC
```

</TabItem>
</Tabs>

**See also:**

- [`ChannelError`](Errors#channelerror)
Expand All @@ -215,13 +375,26 @@ try {

### `addContextListener` (deprecated)

<Tabs>
<TabItem value="ts" label="TypeScript/JavaScript">

```ts
/**
* @deprecated Use `addContextListener(null, handler)` instead of `addContextListener(handler)`
*/
public addContextListener(handler: ContextHandler): Promise<Listener>;
```

</TabItem>
<TabItem value="dotnet" label=".NET">

```csharp
TBC
```

</TabItem>
</Tabs>

Adds a listener for incoming contexts whenever a broadcast happens on the channel.

**See also:**
Expand Down
Loading

0 comments on commit edd0740

Please sign in to comment.