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

Widget networking #61

Closed
Juuxel opened this issue Jun 11, 2020 · 1 comment
Closed

Widget networking #61

Juuxel opened this issue Jun 11, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@Juuxel
Copy link
Member

Juuxel commented Jun 11, 2020

  • Two widget packet types:
    • libgui:clientbound_widget_update
      • Structure: syncId: VarInt, widgetId: String, contents: Buf
    • libgui:serverbound_widget_update
      • Structure: syncId: VarInt, widgetId: String, contents: Buf
  • All networking widgets must have a unique ID of some sort (either a string or an identifier). This can be shared with styles (Styling #60).
  • Only widgets with a synced host can send messages, so hook networking up to validate or createPeers.
  • Example API:
    @Override
    public void validate(GuiDescription host) {
        super.validate(host);
        host.registerWidgetMessageHandler(this, MessageType.S2C, buf -> { /* handle the message */ });
    }
    
    @Override
    public void tick() {
        if (host.isServer()) host.sendWidgetMessage(this, MessageType.S2C, buf -> buf.writeString("hello"));
    }
@Juuxel Juuxel added the enhancement New feature or request label Jun 11, 2020
@Juuxel
Copy link
Member Author

Juuxel commented Dec 17, 2020

Closed by a608419 and 788176d.

@Juuxel Juuxel closed this as completed Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant