I'm having a hard time figuring this out. I'm creating a multiplayer game using the Google Play Games Service API. I want to draw a line on the opponent's screen. Therefore, need to broadcast MotionEvents
. Only one player at a time is allowed to do so. So if the player, who is allowed to broadcast, swipes his finger across the screen, i need to send all the MotionEvents
(ACTION_DOWN
, ACTION_MOVE
, ... , ACTION_MOVE
, ACTION_UP
) to the other opponents. Those opponents need to receive those MotionEvents in the exact same order.
At the moment, i'm broadcasting the MotionEvent right in the moment, when the onTouch()
-Method is called. I have to use sendReliableMessage
, because it must be guaranteed that all the MotionEvents will be received.
I've attached two additional bytes to the message, which identifies the position of a MotionEvent in the received list of MotionEvent
s. One message contains 11 bytes: x-coordinate (4 bytes, float), y-coordinate (4 bytes, float), MotionEvent.Action (1 byte, byte), positionIdentifier (2 bytes, short).
This works, but the latency is very high. One can notice the high latency, because the line drawing looks very unsmooth.
I think it might be because i am sending a lot of packages in a short period of time, but if i wrap many MotionEvent
s into on bigger package, the line drawing would not look smooth, either.
Do you guys have any tips on how i could make this line drawing process look smooth, and not laggy? That would be great.