func (cr *connectionRun) handleMsgFromPeer(msg *msgs.Message) error { if cr.currentState != cr { // probably just draining the queue from the reader after a restart return nil } cr.missingBeats = 0 switch which := msg.Which(); which { case msgs.MESSAGE_HEARTBEAT: // do nothing case msgs.MESSAGE_CLIENTTXNSUBMISSION: ctxn := msg.ClientTxnSubmission() origTxnId := common.MakeTxnId(ctxn.Id()) cr.submitter.SubmitClientTransaction(&ctxn, func(clientOutcome *msgs.ClientTxnOutcome, err error) { switch { case err != nil: cr.clientTxnError(&ctxn, err, origTxnId) case clientOutcome == nil: // shutdown return default: seg := capn.NewBuffer(nil) msg := msgs.NewRootMessage(seg) msg.SetClientTxnOutcome(*clientOutcome) cr.sendMessage(server.SegToBytes(msg.Segment)) } }) default: cr.connectionManager.Dispatchers.DispatchMessage(cr.remoteRMId, which, msg) } return nil }
func (cr *connectionRun) handleMsgFromServer(msg *msgs.Message) error { if cr.currentState != cr { return nil } cr.missingBeats = 0 switch which := msg.Which(); which { case msgs.MESSAGE_HEARTBEAT: // do nothing case msgs.MESSAGE_CLIENTTXNOUTCOME: outcome := msg.ClientTxnOutcome() return cr.handleTxnOutcome(&outcome) default: return fmt.Errorf("Received unexpected message from server: %v", which) } return nil }