Skip to content

Commit

Permalink
fix(fdc3) - Add factory methods for creating channels if necessary, f…
Browse files Browse the repository at this point in the history
…ixed example dialog, added MessageRouterDuplicatEndpointException, added descriptions, removed comments, and todos
  • Loading branch information
lilla28 committed Aug 29, 2024
1 parent c7706ff commit 1360f8f
Show file tree
Hide file tree
Showing 26 changed files with 214 additions and 192 deletions.
2 changes: 1 addition & 1 deletion examples/fdc3-chart-and-grid/js-chart/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async function requestData() {
currentChannel = await window.fdc3.getCurrentChannel();

if(!currentChannel) {
await window.fdc3.joinUserChannel("default");
await window.fdc3.joinUserChannel("fdc3.channel.1");
}

contextListener = await window.fdc3.addContextListener(ContextTypes.Instrument, (context, metadata) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@ export class MockDataService{
private connecting: Promise<void>;

constructor(){
this.market = new Market();
this.connecting = new Promise(async(resolve, reject) => {
try{
resolve(await this.checkFdc3Connection());
} catch(err) {
reject(err);
};
});
this.market = new Market();
this.connecting = new Promise(async(resolve, reject) => {
try{
resolve(await this.checkFdc3Connection());
} catch(err) {
reject(err);
};
});

interval(1000).subscribe(() => {
this.marketData = this.market.generateNewMarketNumbers();
this.subject.next(this.marketData);
});
interval(1000).subscribe(() => {
this.marketData = this.market.generateNewMarketNumbers();
this.subject.next(this.marketData);
});
}

private async checkFdc3Connection(): Promise<void> {
if(!this.connected) {
this.currentChannel = await window.fdc3.getCurrentChannel();
if (!this.currentChannel) {
await window.fdc3.joinUserChannel("default");
await window.fdc3.joinUserChannel("fdc3.channel.1");
}
this.connected = true;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/fdc3-pricing-and-chat/js-chat/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,5 @@ window.app = function () {
window.addEventListener('load', async function () {
intentListener = await window.fdc3.addIntentListener("StartChat", window.app.handleChatIntent);

await window.fdc3.joinUserChannel("default");
await window.fdc3.joinUserChannel("fdc3.channel.1");
});
2 changes: 1 addition & 1 deletion examples/fdc3-pricing-and-chat/js-pricing/pricing.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import "bootstrap/dist/css/bootstrap.css";

window.addEventListener('load', async function () {
const pricingForm = document.querySelector("#pricing");
await this.window.fdc3.joinUserChannel("default");
await this.window.fdc3.joinUserChannel("fdc3.channel.1");
pricingForm.addEventListener('submit', app.submitPrice);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ export class MarketWatchComponent implements OnInit, OnDestroy{
let price: number = 0;
let size = data.quantity;
for (let element of ELEMENT_DATA) {
console.log("current size:", size);
if (size == 0) {
break;
}
Expand Down Expand Up @@ -303,7 +302,6 @@ export class MarketWatchComponent implements OnInit, OnDestroy{
}

for (let innerElement of element.Children) {
console.log("current size:", size);
if (innerElement.Symbol != data.symbol) {
continue;
}
Expand All @@ -318,7 +316,6 @@ export class MarketWatchComponent implements OnInit, OnDestroy{
price = price + innerElement.AskSize * (innerElement.AskPrice == undefined ? 0 : innerElement.AskPrice);
size = size - innerElement.AskSize;
innerElement.AskSize = 0;
console.log("current size: hello", size);
innerElement.LastTrade = data.timestamp;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ <h2 mat-dialog-title>Hi {{data.trader}}</h2>
<p>Please confirm your intent to this symbol {{data.symbol}} with quantity: {{data.quantity}}</p>
</mat-dialog-content>
<mat-dialog-actions>
<button mat-button [mat-dialog-close]="'BUY'" cdkFocusInitial>Buy</button>
<button mat-button [mat-dialog-close]="'SELL'">Sell</button>
<button class="dialog-close" mat-button mat-dialog-close [style.color]="'red'" [style.position]="'absolute'" [style.right]="'20px'">Cancel</button>
<button mat-button [mat-dialog-close]="true" cdkFocusInitial>Confirm</button>
<button class="dialog-close" mat-button [mat-dialog-close]="false" [style.color]="'red'" [style.position]="'absolute'" [style.right]="'20px'">Cancel</button>
</mat-dialog-actions>
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ <h1>Trading App</h1>
</mat-select>
</mat-form-field>

<button mat-icon-button class="sendButton" (click)="broadcastTradeIdea()">
<mat-icon>send</mat-icon>
</button>
<button mat-button class="buyButton" cdkFocusInitial (click)="buySymbol()">Buy</button>
<button mat-button class="sellButton" (click)="sellSymbol()">Sell</button>

<div class="feedback">{{ feedback }}</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export class TradeIdeaGeneratorComponent implements OnDestroy {
}

async ngOnDestroy() {
this.listeners.forEach(async (listener, _) => {
await listener.unsubscribe();
this.listeners.forEach((listener, _) => {
listener.unsubscribe();
});

this.listeners.clear();
Expand Down Expand Up @@ -130,7 +130,7 @@ export class TradeIdeaGeneratorComponent implements OnDestroy {
return !this.wrapValue && inputValue >= this.maximumValue;
}

public async broadcastTradeIdea() : Promise<void> {
private async broadcastTradeIdea(action: string) : Promise<void> {
if (!this.currentValue || this.currentValue <= 0) {
this.feedbackSubject.next('Please select at least 1 quantity.');
return;
Expand All @@ -150,13 +150,11 @@ export class TradeIdeaGeneratorComponent implements OnDestroy {
data: {trader: this.trader!, quantity: this.currentValue, symbol: this.symbols.value as string}
});

dialogRef.afterClosed().subscribe(async result => {
dialogRef.afterClosed().subscribe(async (result: boolean) => {
if (!result) {
return;
}

const action = result as string;

const context: Context = {
type: "fdc3.trade",
data: {
Expand Down Expand Up @@ -201,6 +199,14 @@ export class TradeIdeaGeneratorComponent implements OnDestroy {
}
});
}

public async buySymbol() : Promise<void> {
await this.broadcastTradeIdea("BUY");
}

public async sellSymbol() : Promise<void> {
await this.broadcastTradeIdea("SELL");
}
}

@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public async ValueTask Connect()

await MessagingService.ConnectAsync();

await MessagingService.RegisterServiceAsync(_topics.GetCurrentContext, GetCurrentContext);

var broadcastHandler = new Func<IMessageBuffer, ValueTask>(HandleBroadcast);
var broadcastSubscription = MessagingService.SubscribeAsync(_topics.Broadcast, broadcastHandler);

await MessagingService.RegisterServiceAsync(_topics.GetCurrentContext, GetCurrentContext);
_broadcastSubscription = await broadcastSubscription;


LogConnected();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

using Microsoft.Extensions.Options;
using MorganStanley.ComposeUI.Fdc3.DesktopAgent.Protocol;

namespace MorganStanley.ComposeUI.Fdc3.DesktopAgent.DependencyInjection;

Expand All @@ -28,6 +29,11 @@ public sealed class Fdc3DesktopAgentOptions : IOptions<Fdc3DesktopAgentOptions>
/// </summary>
public Uri? UserChannelConfigFile { get; set; }

/// <summary>
/// Sets the UserChannel set.
/// </summary>
public ChannelItem[]? UserChannelConfig { get; set; }

/// <summary>
/// Indicates a timeout value for getting the IntentResult from the backend in milliseconds.
/// When set to any value, it sets the timeout for the getResult() client calls, which should wait either for this timeout or the task which gets the appropriate resolved IntentResolution.
Expand Down
Loading

0 comments on commit 1360f8f

Please sign in to comment.