Open the endpoint's notebox
(ctx context.Context, session *HubSession, deviceUID string, deviceSN string, productUID string, endpointID string, event EventFunc)
| 437 | |
| 438 | // Open the endpoint's notebox |
| 439 | func openHubNoteboxForDevice(ctx context.Context, session *HubSession, deviceUID string, deviceSN string, productUID string, endpointID string, event EventFunc) (box *Notebox, ei *NotefileEventInfo, appUID string, err error) { |
| 440 | timerName := timerBegin(ctx, "openNoteboxForDevice") |
| 441 | defer timerEnd(ctx, timerName) |
| 442 | |
| 443 | // Warn if this take too long; it should be a few milliseconds |
| 444 | start := time.Now() |
| 445 | defer func() { |
| 446 | if time.Since(start) > time.Second { |
| 447 | session.LogWarn(ctx, "[timewarn] excessively long time to open the notebox: %s", time.Since(start)) |
| 448 | } |
| 449 | }() |
| 450 | |
| 451 | // Ensure that hub endpoint is available |
| 452 | var hubEndpointID, deviceStorageObject string |
| 453 | timerName = timerBegin(ctx, "hubDiscover") |
| 454 | hubEndpointID, appUID, deviceStorageObject, err = HubDiscover(deviceUID, deviceSN, productUID, appUID) |
| 455 | timerEnd(ctx, timerName) |
| 456 | if err != nil { |
| 457 | return |
| 458 | } |
| 459 | |
| 460 | // Open the endpoint's box on behalf of the Notehub, because we can't open it directly under the device endpoint IDs |
| 461 | timerName = timerBegin(ctx, "openNotebox`") |
| 462 | box, err = OpenEndpointNotebox(ctx, hubEndpointID, deviceStorageObject, true) |
| 463 | timerEnd(ctx, timerName) |
| 464 | if err != nil { |
| 465 | return |
| 466 | } |
| 467 | |
| 468 | // Set the default notification context for files opened within this box instance |
| 469 | ei = EventInfo(deviceUID, deviceSN, productUID, appUID, session.Session.Transport, event, session) |
| 470 | |
| 471 | // If we haven't yet enum'ed the notefiles, do so |
| 472 | sawNotefile(session, box, "") |
| 473 | |
| 474 | // Done |
| 475 | return |
| 476 | } |
| 477 | |
| 478 | // Ensure that the specified notefile is in the list |
| 479 | func sawNotefile(session *HubSession, box *Notebox, notefileID string) { |
no test coverage detected