func (nm *networkManager) Invite(ctx *context.T, call rpc.ServerCall) error { inviter := call.RemoteEndpoint().Name() response := make(chan error) nm.inviteRPCs <- Invitation{ Name: inviter, Color: selectColor(call.Security().RemoteBlessings().PublicKey()), Response: response, Withdrawn: ctx.Done(), } if err := <-response; err != nil { return err } blessings, rejected := security.RemoteBlessingNames(ctx, call.Security()) ctx.Infof("Accepted invitation from %v@%v (rejected blessings: %v)", blessings, inviter, rejected) return nil }
func (nm *networkManager) Give(ctx *context.T, call rpc.ServerCall, t spec.Triangle) error { if ctx.V(3) { blessings, rejected := security.RemoteBlessingNames(ctx, call.Security()) ctx.Infof("Took a triangle from %v@%v (rejected blessings: %v)", blessings, call.RemoteEndpoint().Name(), rejected) } // Transform from sender's coordinates to our coordinates. // The assumption is that if the triangle was to the left of the // sender's coordinate system, then it will appear on our right and // vice-versa. switch { case t.X < -1: t.X += 2 case t.X > 1: t.X -= 2 } nm.myScreen <- &t return nil }