@@ -54,64 +54,64 @@ func main() {
5454}
5555
5656func (c * Client ) register () {
57- controllerReply := refproto.ControllerReply {}
58- if err := sslconn .ReceiveMessage (c .conn , & controllerReply ); err != nil {
57+ reply := refproto.ControllerToTeam {}
58+ if err := sslconn .ReceiveMessage (c .conn , & reply ); err != nil {
5959 log .Fatal ("Failed receiving controller reply: " , err )
6060 }
61- if controllerReply .NextToken == nil {
61+ if reply . GetControllerReply () .NextToken == nil {
6262 log .Fatal ("Missing next token" )
6363 }
6464
6565 registration := refproto.TeamRegistration {}
6666 registration .TeamName = teamName
6767 if privateKey != nil {
68- registration .Signature = & refproto.Signature {Token : controllerReply .NextToken , Pkcs1V15 : []byte {}}
68+ registration .Signature = & refproto.Signature {Token : reply . GetControllerReply () .NextToken , Pkcs1V15 : []byte {}}
6969 registration .Signature .Pkcs1V15 = client .Sign (privateKey , & registration )
7070 }
7171 log .Print ("Sending registration" )
7272 if err := sslconn .SendMessage (c .conn , & registration ); err != nil {
7373 log .Fatal ("Failed sending registration: " , err )
7474 }
7575 log .Print ("Sent registration, waiting for reply" )
76- controllerReply = refproto.ControllerReply {}
77- if err := sslconn .ReceiveMessage (c .conn , & controllerReply ); err != nil {
76+ reply = refproto.ControllerToTeam {}
77+ if err := sslconn .ReceiveMessage (c .conn , & reply ); err != nil {
7878 log .Fatal ("Failed receiving controller reply: " , err )
7979 }
80- if controllerReply . StatusCode == nil || * controllerReply .StatusCode != refproto .ControllerReply_OK {
80+ if reply . GetControllerReply (). StatusCode == nil || * reply . GetControllerReply () .StatusCode != refproto .ControllerReply_OK {
8181 reason := ""
82- if controllerReply .Reason != nil {
83- reason = * controllerReply .Reason
82+ if reply . GetControllerReply () .Reason != nil {
83+ reason = * reply . GetControllerReply () .Reason
8484 }
8585 log .Fatal ("Registration rejected: " , reason )
8686 }
8787 log .Printf ("Successfully registered as %v" , * teamName )
88- if controllerReply .NextToken != nil {
89- c .token = * controllerReply .NextToken
88+ if reply . GetControllerReply () .NextToken != nil {
89+ c .token = * reply . GetControllerReply () .NextToken
9090 } else {
9191 c .token = ""
9292 }
9393}
9494
9595func (c * Client ) sendDesiredKeeper (id int32 ) {
96- message := refproto.TeamToControllerRequest_DesiredKeeper {DesiredKeeper : id }
97- request := refproto.TeamToControllerRequest { Request : & message }
96+ message := refproto.TeamToController_DesiredKeeper {DesiredKeeper : id }
97+ request := refproto.TeamToController { Msg : & message }
9898 c .sendRequest (& request )
9999}
100100
101101func (c * Client ) ReplyToChoices () {
102- request := refproto.ControllerToTeamRequest {}
102+ request := refproto.ControllerToTeam {}
103103 if err := sslconn .ReceiveMessage (c .conn , & request ); err != nil {
104104 log .Fatal ("Failed receiving controller request: " , err )
105105 }
106106 if request .GetAdvantageChoice () != nil {
107107 log .Printf ("Received choice for: %v" , * request .GetAdvantageChoice ().Foul )
108108 }
109- reply := refproto.TeamToControllerRequest_AdvantageResponse_ {AdvantageResponse : refproto .TeamToControllerRequest_CONTINUE }
110- response := refproto.TeamToControllerRequest { Request : & reply }
109+ reply := refproto.TeamToController_AdvantageResponse_ {AdvantageResponse : refproto .TeamToController_CONTINUE }
110+ response := refproto.TeamToController { Msg : & reply }
111111 c .sendRequest (& response )
112112}
113113
114- func (c * Client ) sendRequest (request * refproto.TeamToControllerRequest ) {
114+ func (c * Client ) sendRequest (request * refproto.TeamToController ) {
115115 if privateKey != nil {
116116 request .Signature = & refproto.Signature {Token : & c .token , Pkcs1V15 : []byte {}}
117117 request .Signature .Pkcs1V15 = client .Sign (privateKey , request )
@@ -124,16 +124,16 @@ func (c *Client) sendRequest(request *refproto.TeamToControllerRequest) {
124124 }
125125
126126 log .Print ("Waiting for reply..." )
127- controllerReply := refproto.ControllerReply {}
128- if err := sslconn .ReceiveMessage (c .conn , & controllerReply ); err != nil {
127+ reply := refproto.ControllerToTeam {}
128+ if err := sslconn .ReceiveMessage (c .conn , & reply ); err != nil {
129129 log .Fatal ("Failed receiving controller reply: " , err )
130130 }
131- log .Print ("Received reply: " , controllerReply )
132- if controllerReply . StatusCode == nil || * controllerReply .StatusCode != refproto .ControllerReply_OK {
133- log .Fatal ("Message rejected: " , * controllerReply .Reason )
131+ log .Print ("Received reply: " , reply )
132+ if reply . GetControllerReply (). StatusCode == nil || * reply . GetControllerReply () .StatusCode != refproto .ControllerReply_OK {
133+ log .Print ("Message rejected: " , * reply . GetControllerReply () .Reason )
134134 }
135- if controllerReply .NextToken != nil {
136- c .token = * controllerReply .NextToken
135+ if reply . GetControllerReply () .NextToken != nil {
136+ c .token = * reply . GetControllerReply () .NextToken
137137 } else {
138138 c .token = ""
139139 }
0 commit comments