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 websockets v2 #1978

Merged
merged 10 commits into from
Feb 20, 2023
Merged

Add websockets v2 #1978

merged 10 commits into from
Feb 20, 2023

Conversation

lmoe
Copy link
Contributor

@lmoe lmoe commented Feb 20, 2023

Description of change

Adds a new websocket to the webapi.

To be found on ws://api.wasphost/ws

Supports subscribing to message topics

{ "command": "subscribe", "topic": "request" }

Supports subscribing to chains (either all, or selected)

{ "command": "subscribe", "topic": "chains" }
{ "command": "subscribe", "topic": "chains/<chainID>" }

Links to any relevant issues

fixes issue #1414

plugins/webapi/component.go Outdated Show resolved Hide resolved
packages/publisher/publisherws/publisherws.go Show resolved Hide resolved
default:
p.log.Warnf("dropping websocket message for %s", r.RemoteAddr)
if err := client.Send(ctx, event); err != nil {
p.log.Warnf("error sending message: %v", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe add the info to which client ID the send failed.

packages/publisher/publisherws/publisherws.go Show resolved Hide resolved

var command SubscriptionCommand
if err := json.Unmarshal(message, &command); err != nil {
p.log.Warnf("Could not deserialize message to type ControlCommand, msg: '%v'", message)
Copy link
Collaborator

Choose a reason for hiding this comment

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

you will print a byte slice here as a log message. better encode it to hex before.

Copy link
Collaborator

Choose a reason for hiding this comment

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

And add the info about the client.

packages/publisher/publisherws/publisherws.go Show resolved Hide resolved
packages/publisher/publisherws/publisherws.go Show resolved Hide resolved
packages/publisher/publisherws/publisherws.go Show resolved Hide resolved
packages/publisher/publisherws/publisherws.go Show resolved Hide resolved
packages/publisher/publisherws/publisherws.go Show resolved Hide resolved
packages/publisher/publisherws/publisherws.go Show resolved Hide resolved
Copy link
Collaborator

@muXxer muXxer left a comment

Choose a reason for hiding this comment

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

The requested changes will be made later on by @lmoe

@muXxer muXxer merged commit 6e65be7 into develop Feb 20, 2023
@muXxer muXxer deleted the add_websockets_v2 branch February 20, 2023 17:13
@lmoe lmoe mentioned this pull request Feb 21, 2023
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