Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Electron Web Sample #7

Merged
merged 11 commits into from
Oct 3, 2017
Merged

Add Electron Web Sample #7

merged 11 commits into from
Oct 3, 2017

Conversation

msach22
Copy link
Contributor

@msach22 msach22 commented Sep 28, 2017

No description provided.

@msach22 msach22 changed the title Add Electron Web Sample Add Electron Web Sample - Don't merge Sep 28, 2017
@msach22 msach22 changed the title Add Electron Web Sample - Don't merge Add Electron Web Sample Sep 28, 2017
@davemun davemun assigned davemun and unassigned davemun Sep 28, 2017
Copy link

@davemun davemun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know a lot of it is nitpicky, but a code sample should exhibit as clear and concise a code whenever possible.


The Session object dispatches a `streamDestroyed` event when the stream is Destroyed. The application defines an event handler for this event:

session.on({
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Escape this into a code block.

Copy link
Contributor Author

@msach22 msach22 Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the latest commit

Once the Publisher object is initialized, we publish to the session using the `publish()`
method of the Session object:

session.publish(publisher, (error) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also escape this into a code block.

Copy link
Contributor Author

@msach22 msach22 Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the latest commit


* When starting the application, you'll notice a silent error:
`ERROR:audio_send_stream.cc(93)] Failed to set up send codec state.`
This is a known [Electron issue](https://github.com/electron/electron/issues/8991).
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add next steps for the reader? If it's a known issue, what do they do next? e.g. wait for electron team to resolve, a workaround, restart?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the latest commit

}));

// Open the DevTools.
// mainWindow.webContents.openDevTools()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this if you aren't using it as part of the sample.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the latest commit

// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line termination char

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the latest commit

session.on({
streamCreated: (event) => {
session.subscribe(event.stream, 'subscriber', (error) => {
if (error) console.log(`There was an issue subscribing to the stream ${event}`);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if brace style should be consistent - if you do one-liners, use one-liners always when possible. If you don't, always use brackets. There's some file-wide variation that can be confusing for someone who is unfamiliar with the language.

IMHO I would recommend brackets always - the default ESLint style can be found here: https://eslint.org/docs/rules/brace-style#options
e.g.

if (cond) {
  action();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the latest commit

});
},
streamDestroyed: (event) => {
console.log(`Stream ${event.stream.name} ended ${event.reason}`);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think some better sentence structure could go a long way for the console logs when you're interpolating event params in this sample repo. Otherwise the intent of the injection is not clear.

e.g. Stream with name: ${name} ended because of reason: ${reason}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the latest commit

session.connect(token, (error) => {
// If the connection is successful, initialize a publisher and publish to the session
if (error) {
return console.log('error connecting to session', error);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add spacing like 'Error connecting to session: ' + error.reason?

Otherwise you'd get "error connection to sessionError: eventReasonHere" which is less readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the latest commit

//Initialize Session
const session = OT.initSession(apiKey, sessionId);

//Set session event listeners
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space after //

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the latest commit

const sessionId = "";
const token = "";

//Initialize Session
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space after //

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the latest commit

session.on({
streamCreated: (event) => {
session.subscribe(event.stream, 'subscriber', (error) => {
if (error) console.log(`There was an issue subscribing to the stream ${event}`);
if (error) {
console.log(`There was an issue subscribing to the stream ${event}`);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong: why are we logging the event instead of the error?
Can you also fix the aforementioned stream with error: ${error} concat?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes sir

This is a known [Electron issue](https://github.com/electron/electron/issues/8991).
`ERROR:audio_send_stream.cc(93)] Failed to set up send codec state.`
This is a known [Electron issue](https://github.com/electron/electron/issues/8991).
We recommend staying up to date with the issue to see if the Electron team or other contributors have a solution
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a period after solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

return console.log('There was an error publishing', error);
}
});
session.publish(publisher, (error) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still not in a code block.

Open the file in the Github UI to see the rendered markdown view.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i read your comment incorrectly my b, fixing in next commit

Copy link

@davemun davemun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@msach22 msach22 merged commit 8f2124d into opentok:master Oct 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants