コード例 #1
0
func (tm *netwkTesterMaker) Make() MatchTester {
	serverPort := tm.freePort
	tm.freePort++
	clientPort := tm.freePort
	tm.freePort++
	// Build matcher
	m := NewMatcher(100)
	coordinator.InMemory(mkReadConn(serverPort), mkWriteConn(clientPort), m, matcherOrigin, "Matching Engine", false)
	// Build client
	receivedMsgs := make(chan *msg.Message, 1000)
	toSendMsgs := make(chan *msg.Message, 1000)
	c := newClient(receivedMsgs, toSendMsgs)
	coordinator.InMemory(mkReadConn(clientPort), mkWriteConn(serverPort), c, clientOrigin, "Test Client    ", false)
	return &netwkTester{receivedMsgs: receivedMsgs, toSendMsgs: toSendMsgs}
}
コード例 #2
0
func (tm *netwkTesterMaker) Make() MatchTester {
	serverPort := tm.freePort
	tm.freePort++
	clientPort := tm.freePort
	tm.freePort++
	// Build matcher
	m := NewMatcher(100)
	coordinator.InMemory(mkReadConn(serverPort), mkWriteConn(clientPort), m, 0, "Matching Engine", false)
	// Build client
	fromListener, toResponder := coordinator.InMemoryListenerResponder(mkReadConn(clientPort), mkWriteConn(serverPort), "Test Client    ", false)
	return &netwkTester{receivedMsgs: fromListener, toSendMsgs: toResponder}
}
コード例 #3
0
ファイル: main.go プロジェクト: vdt/matching_engine
func main() {
	pwd, err := os.Getwd()
	if err != nil {
		println(err.Error())
		return
	}
	// Create matching engine + client
	clientToServer := q.NewSimpleQ("Client To Server")
	serverToClient := q.NewSimpleQ("Server To Client")
	// Matching Engine
	m := matcher.NewMatcher(100)
	var traderClient *client.C
	traderClient, commMaker = client.NewClient()
	coordinator.InMemory(serverToClient, clientToServer, traderClient, clientOriginId, "Client.........", true)
	coordinator.InMemory(clientToServer, serverToClient, m, serverOriginId, "Matching Engine", true)
	http.Handle("/wsconn", websocket.Handler(handleTrader))
	http.Handle("/", http.FileServer(http.Dir(pwd+"/html/")))
	if err := http.ListenAndServe("127.0.0.1:8081", nil); err != nil {
		println(err.Error())
	}
}