func (s *Socket) handleMessagesOut() {
	for {
		e := <-s.events
		log.Printf("Received an event")
		switch e.eventType {
		case ORDER_PLACED:
			order := e.payload.(*Order)
			s.sendOrderPlaced(order)
		case ORDER_PARTIALLY_FILLED:
			order := e.payload.(*TradePayload)
			s.sendOrderPartiallyFilled(order)
		case ORDER_FILLED:
			payload := e.payload.(*TradePayload)
			s.sendOrderFilled(payload)
		case ORDER_CANCELED:
			order := e.payload.(*Order)
			s.sendOrderCanceled(order)
		case ORDER_EXECUTED:
			log.Printf("Trade has bee executed")
			order := e.payload.(*Order)
			s.sendOrderExecuted(order)
		case ORDER_TX_SUCCESS:
			log.Printf("Order TX success")
			order := e.payload.(*Order)
			s.sendOrderTxSuccess(order)
		case ORDER_TX_ERROR:
			log.Printf("Order TX error")
			order := e.payload.(*Order)
			s.sendOrderTxSuccess(order)
		case TRADE_EXECUTED:
			log.Printf("Trade executed")
			trade := e.payload.(*Trade)
			s.sendTradeExecuted(trade)
		case TRADE_TX_SUCCESS:
			log.Printf("Trade Tx Success")
			trade := e.payload.(*Trade)
			s.sendTradeTxSuccess(trade)
		case TRADE_TX_ERROR:
			log.Printf("Trade Tx Error")
			trade := e.payload.(*Trade)
			s.sendTradeTxSuccess(trade)
		case DONE:
		default:
			panic("Unknown action type")
		}
	}
}
// handleMessagesOut listens on the event channel (events sent from the matching engine) and routes them
// to the appropriate handler based on their event type
handleMessagesOut listens on the event channel (events sent from the matching engine) and routes them
to the appropriate handler based on their event type
// handleMessagesOut listens on the event channel ( events sent from the matching engine ) and routes them // to the appropriate handler based on their event type
func (s *Socket) handleMessagesOut() {
	for {
		e := <-s.events
		log.Printf("Received an event")
		switch e.eventType {
		case ORDER_PLACED:
			order := e.payload.(*Order)
			s.sendOrderPlaced(order)
		case ORDER_PARTIALLY_FILLED:
			order := e.payload.(*TradePayload)
			s.sendOrderPartiallyFilled(order)
		case ORDER_FILLED:
			payload := e.payload.(*TradePayload)
			s.sendOrderFilled(payload)
		case ORDER_CANCELED:
			order := e.payload.(*Order)
			s.sendOrderCanceled(order)
		case ORDER_EXECUTED:
			log.Printf("Trade has bee executed")
			order := e.payload.(*Order)
			s.sendOrderExecuted(order)
		case ORDER_TX_SUCCESS:
			log.Printf("Order TX success")
			order := e.payload.(*Order)
			s.sendOrderTxSuccess(order)
		case ORDER_TX_ERROR:
			log.Printf("Order TX error")
			order := e.payload.(*Order)
			s.sendOrderTxSuccess(order)
		case TRADE_EXECUTED:
			log.Printf("Trade executed")
			trade := e.payload.(*Trade)
			s.sendTradeExecuted(trade)
		case TRADE_TX_SUCCESS:
			log.Printf("Trade Tx Success")
			trade := e.payload.(*Trade)
			s.sendTradeTxSuccess(trade)
		case TRADE_TX_ERROR:
			log.Printf("Trade Tx Error")
			trade := e.payload.(*Trade)
			s.sendTradeTxSuccess(trade)
		case DONE:
		default:
			panic("Unknown action type")
		}
	}
}
func ( s * Socket ) handleMessagesOut ( ) { for { e := <- s . events log . Printf ( " " ) switch e . eventType { case ORDER_PLACED : order := e . payload . ( * Order ) s . sendOrderPlaced ( order ) case ORDER_PARTIALLY_FILLED : order := e . payload . ( * TradePayload ) s . sendOrderPartiallyFilled ( order ) case ORDER_FILLED : payload := e . payload . ( * TradePayload ) s . sendOrderFilled ( payload ) case ORDER_CANCELED : order := e . payload . ( * Order ) s . sendOrderCanceled ( order ) case ORDER_EXECUTED : log . Printf ( " " ) order := e . payload . ( * Order ) s . sendOrderExecuted ( order ) case ORDER_TX_SUCCESS : log . Printf ( " " ) order := e . payload . ( * Order ) s . sendOrderTxSuccess ( order ) case ORDER_TX_ERROR : log . Printf ( " " ) order := e . payload . ( * Order ) s . sendOrderTxSuccess ( order ) case TRADE_EXECUTED : log . Printf ( " " ) trade := e . payload . ( * Trade ) s . sendTradeExecuted ( trade ) case TRADE_TX_SUCCESS : log . Printf ( " " ) trade := e . payload . ( * Trade ) s . sendTradeTxSuccess ( trade ) case TRADE_TX_ERROR : log . Printf ( " " ) trade := e . payload . ( * Trade ) s . sendTradeTxSuccess ( trade ) case DONE : default : panic ( " " ) } } }
handleMessagesOut listens on the event channel (events sent from the matching engine) and routes them
to the appropriate handler based on their event type
handleMessagesOut listens on the event channel ( events sent from the matching engine ) and routes them to the appropriate handler based on their event type