-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[exemple] Create simple client, like in demo #67
Comments
I'm trying to create like this :
But ascii-parser error : |
the problem is under covers there are objects that need to be constructed each using the config object so config is created and then injected to the other objects. the demo uses a stubed server just to show messages being sent but this is not needed you cant really strip it down mch more than below as you have to return your session object into the DI container so it is sitting alongside all other objects such as parser sender buffer and so on. this can be placed essentially in your startup the entire rest of your application can work as you like including the implentation of the FixTest it has been many months since I looked in detail at this project but initialising everything is actually quite complex as there is a lot to construct which is why eventually dependency injection was used so each object has its dependencies created including the config object. import 'reflect-metadata'
import { TradeCaptureClient } from './trade-capture-client'
import { EngineFactory, IJsFixConfig, SessionLauncher } from 'jspurefix'
class AppLauncher extends SessionLauncher {
public constructor (client: string = '../../test-initiator.json') {
super(client)
this.root = __dirname
}
protected override makeFactory (config: IJsFixConfig): EngineFactory {
return {
makeSession: () => new FixTest (config)
} as EngineFactory
}
}
const l = new AppLauncher()
l.exec() |
there is also https://github.com/TimelordUK/jspf-md-demo whch uses commad line to optionally add in a server along with other paramaters this has 2 methods of stating either using a DI container or something like aboev - it also shows how you can add your own web service into the initialisation it may provide a different start point - once you know which way you want to initialise the other code can be remoed as youu only need one - this is dictated by the command line. e.g. cd dist/app && node app --port 3000 --server ../../data/session/test-acceptor.json ❯ cd dist/app && node app --port 3000 --server ../../data/session/test-acceptor.json
port: 3000, DI: using factory
2023-08-27T14:31:10.144Z [launcher] info: launching ..
2023-08-27T14:31:10.148Z [launcher] info: creating app test_server [protocol ascii]
2023-08-27T14:31:10.206Z [launcher] info: creating app test_client [protocol ascii]
2023-08-27T14:31:10.207Z [launcher] info: launching ....
2023-08-27T14:31:11.741Z [launcher] info: create initiator
2023-08-27T14:31:11.742Z [initiator] info: create session with DI Token FixSession
2023-08-27T14:31:11.864Z [initiator] info: connecting ...
2023-08-27T14:31:11.865Z [test_client:TcpInitiator] info: connecting with timeout 22
2023-08-27T14:31:11.867Z [test_client:TcpInitiator] info: unsecureDuplex try to connect to endPoint
2023-08-27T14:31:11.878Z [test_client:TcpInitiator] info: tryConnect localhost:2344
2023-08-27T14:31:11.880Z [launcher] info: create acceptor
2023-08-27T14:31:11.885Z [acceptor] info: starting.
2023-08-27T14:31:11.886Z [test_server:TcpAcceptor] info: create unsecured server
2023-08-27T14:31:11.887Z [test_server:TcpAcceptor] info: start to listen 2344
2023-08-27T14:31:11.893Z [test_client:TcpInitiator] info: net.createConnection cb, resolving
txt |
Thank you for the quick reply. |
Hi, thanks for this great library.
I hope understand to use it. ;-)
I'm trying create exemple like in demo, but it seem complex.
Is it possible to create single client, from configuration json file ?
Or create IJsFixConfig object from json file ?
I'm just trying to create client fix session, but i'm stuck.
The text was updated successfully, but these errors were encountered: