1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package main
- import (
- "fmt"
- "lmaxapi"
- "lmaxapi/main/common"
- "tickserver/api/lmaxapi/request"
- "tickserver/api/lmaxapi/response"
- "time"
- )
- func main() {
- fmt.Println("AccountEventsClient")
- session, err := common.CreateSession()
- if err != nil {
- // fmt.Println("Login Failed:", err)
- return
- }
- go func() {
- session.KeepAlive(30 * time.Second)
- }()
- session.RegisterAccountStateEvent(func(s *lmaxapi.Session, event *response.AccountStateEvent) {
- // fmt.Println(event)
- })
- session.RegisterHeartbeatEvent(func(s *lmaxapi.Session, id int64, token string) {
- // fmt.Println("heartbeat accountId:", id)
- })
- c := make(chan int, 0)
- session.Subscribe(request.NewAccountSubscriptionRequest(), func(err error) {
- session.Start()
- c <- 1
- })
- common.Heartbeat(session)
- <-c
- //session.start
- }
|