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

Fixed several bugs with notifications #16

Merged
merged 4 commits into from
Apr 24, 2017
Merged

Conversation

ekzobrain
Copy link
Contributor

Fixed method JsonRpcConsumer.notify_channel()
Fixed inbound http/websocket notifications to return correct transport-specific results

Fixed inbound http/websocket notifications to return correct transport-specific results
@@ -253,12 +267,12 @@ def __handle(self, content, message):
else:
if isinstance(data, dict):

if data.get('method') is not None and data.get('params') is not None and data.get('id') is None:
Copy link
Owner

Choose a reason for hiding this comment

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

@soulhunter1987
Why did you remove the check for 'params' and 'method'?
That is what make the tests fail.

If sending {"value": "my_value"} which should be received as a wrongly formatted JSON-RPC frame, it handles it as a notification,....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right here, I did not think about such case. I'll change this back now...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

# Send responce back
self.send(text=self._encode(result))
# Send responce back only if it is a call, not notification
if result_type == 0:
Copy link
Owner

Choose a reason for hiding this comment

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

@soulhunter1987
please use some GLOBAL_VAR for the result_type:
RESULT_NOTIFICATION_TYPE/RESULT_REQUEST_TYPE, for clarity purposes, or 'is_notification as variable name' ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course it should be done, but for now It is just a quick working solution. These lines would anywhere look different after moving to a JSON-RPC decoding/encoding library, and I plan to do it soon, because I need support of batch calls, and, may be, protocol versions 1.1/1.2 along with 2.0. So this is a temporary working 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.

Pushed a quick fix

@ekzobrain
Copy link
Contributor Author

I pushed one more fix with contant usage of JsonRpcConsumer._encode() to simplify json encoder configuration.

@millerf millerf merged commit 73fd19e into millerf:master Apr 24, 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.

None yet

2 participants