PocketMine-MP icon indicating copy to clipboard operation
PocketMine-MP copied to clipboard

Add sendToast method, API to send toast with ToastRequestPacket

Open yuyaprgrm opened this issue 3 years ago • 4 comments
trafficstars

Introduction

Since Bedrock 1.19.0, there is a ToastRequestPacket but there is no API to send toast.

Relevant issues

No

Changes

API changes

add Player::sendToast(string $title, string $body): void

Behavioural changes

No

Backwards compatibility

There is no BC break.

Follow-up

Tests

$player->sendToast("title", "body");

image

yuyaprgrm avatar Jun 07 '22 22:06 yuyaprgrm

It seems to me that it would be more logical to addToast, because Toasts queue up if, e.g. send more than two.

ghost avatar Jun 08 '22 11:06 ghost

Looks cool

rac14 avatar Jun 14 '22 01:06 rac14

It seems to me that it would be more logical to addToast, because Toasts queue up if, e.g. send more than two.

Chat messages queue up in the chat pane too.

SOF3 avatar Jun 14 '22 07:06 SOF3

But the chat does not have such a significant delay as Toasts...

ghost avatar Jun 20 '22 22:06 ghost

I'm not sure sendToast() is a clear enough name. It doesn't translate very well.

That said, there is a precedent in the Android API, so I'm unsure if it needs to be changed. Thoughts?

dktapps avatar Aug 15 '22 15:08 dktapps

At the least, there should be a small docblock that describes what the function does, since the function's name is not very intuitive.

dktapps avatar Aug 15 '22 15:08 dktapps

I'm not sure sendToast() is a clear enough name. It doesn't translate very well.

That said, there is a precedent in the Android API, so I'm unsure if it needs to be changed. Thoughts?

I think it would be better to change method name to sendNotification, since toast is used to notify users such as excessive game playing, achievements, etc.

alvin0319 avatar Sep 15 '22 04:09 alvin0319

I want to take a survey in this PR.

Should send be used for this method name or not?

At first, I thought send is good naming because it was used in all sending text method like sendMessage, sendTitle, sendTip and sendPopup, but I found that toasts have different behavior than these methods above.

But the chat does not have such a significant delay as Toasts...

Yes, it delays. If there is already a toast text shown in game screen, the new toast waits for the former toast to disappear. I may change method name or just add a description in docblock.

Which is better name for this method?

As Dylan pointed out, sendToast may unclear name to describe its functionality. Also, alvin gives a good name for this method, sendNotification.

I want to know which is better name for this method. Or add other idea. 🅰️ sendToast 🅱️ sendNotification

yuyaprgrm avatar Sep 15 '22 10:09 yuyaprgrm

I think sendToastNotification() or sendToastMessage() makes the most sense, since both sendToast() and sendNotification() are ambiguous at first glance.

dktapps avatar Sep 15 '22 11:09 dktapps

I like sendToast() + docblock. As dylan said, there is precedent in the Android API and I don't think it needs to be changed.

Nerahikada avatar Sep 15 '22 14:09 Nerahikada

I think sendToast() + docblock or sendToastPopup() are ok, would be descriptive and simple.

IvanCraft623 avatar Sep 23 '22 03:09 IvanCraft623