wavelength 1.0.0
Loading...
Searching...
No Matches
joinpadrt.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4
5#include "app/msgsink.h"
6#include "game/remixinfo.h"
9
10class BootPkt;
11class ChatMsg;
12class ClientInfoPkt;
13class ClockSyncTask;
14class DataBlockPkt;
15class GameOverPkt;
16class GameParamsPkt;
17class JoinFailedPkt;
18class ShareRemixPkt;
19class TimeResponsePkt;
20class WelcomePkt;
21
30class JoinpadRT : public LaunchpadRT {
31public:
42 static void Create(MsgSink *pScreen, MsgSink *pGame, int nWorldId, int nHostAccount);
43
54 JoinpadRT(MsgSink *pScreen, MsgSink *pGame, int nWorldId, int nHostAccount);
55
62 ~JoinpadRT() override;
63
71 void RemovePlayer(int nId) override;
72
80 float GetTime() override;
81
88 void OnConnected() override;
89
96 void PollPriv() override;
97
98#ifdef VIDEO_STANDARD_PAL
104 void NotifyLoaded() override;
105
114 void PollStart();
115#endif
116
125 bool DispatchPriv(Message *pMsg) override;
126
136 void RequestKey(int nHostAccount);
137
148 void OnClockSynced(float fOffset, float fRoundTrip);
149
160 bool OnMsg(WelcomePkt *pPkt);
161
170 bool OnMsg(JoinFailedPkt *pPkt);
171
180 bool OnMsg(ClientInfoPkt *pPkt);
181
191
200 bool OnMsg(GameParamsPkt *pPkt);
201
210 bool OnMsg(BootPkt *pPkt);
211
220 bool OnMsg(GameOverPkt *pPkt);
221
230 bool OnMsg(ShareRemixPkt *pPkt);
231
240 bool OnMsg(DataBlockPkt *pPkt);
241
250 bool OnMsg(ChatMsg *pMsg);
251
252 using LaunchpadRT::OnMsg;
253
255 int GetKeyReceived() const {
256 return mKeyReceived;
257 }
258
261 return mClockSync.get();
262 }
263
265 const NetGameParams &GetParams() const {
266 return mParams;
267 }
268
270 float GetClockOffset() const {
271 return mClockOffset;
272 }
273
275 const RemixInfo &GetRemixInfo() const {
276 return mRemixInfo;
277 }
278
279private:
280 int mKeyReceived;
281 std::unique_ptr<ClockSyncTask> mClockSync;
282 NetGameParams mParams;
283 float mClockOffset;
284 int mReserved1D4; // +0x1d4, the alignment of mRemixInfo to eight bytes.
285 RemixInfo mRemixInfo;
286};
287
294extern JoinpadRT *TheJoinpadRT;
Packet the host sends every console when it removes a guest from the session.
Definition bootpkt.h:20
Message with one line of chat between the consoles of an online session or lobby.
Definition chatmsg.h:24
Packet that describes one player of the session.
Definition clientinfopkt.h:21
Task of a guest that measures the clock of the host.
Definition clocksynctask.h:15
Packet that delivers one block of the remix the host shares.
Definition datablockpkt.h:20
Packet that reports the final scores of the song.
Definition gameoverpkt.h:23
Packet the host sends when the settings of the game change.
Definition gameparamspkt.h:21
Packet the host sends a console it turns away.
Definition joinfailedpkt.h:20
The online session of a console that joins it.
Definition joinpadrt.h:30
float GetTime() override
Report the clock of the host.
bool OnMsg(GameParamsPkt *pPkt)
Pass the settings the host published to mGameSink, or exit for a song this console lacks.
bool OnMsg(DataBlockPkt *pPkt)
Store a block of the remix the host shares and acknowledge it.
bool DispatchPriv(Message *pMsg) override
Act on a packet of the session, before LaunchpadRT does.
void PollPriv() override
Poll mClockSync.
const NetGameParams & GetParams() const
Definition joinpadrt.h:265
static void Create(MsgSink *pScreen, MsgSink *pGame, int nWorldId, int nHostAccount)
Start joining a session.
bool OnMsg(JoinFailedPkt *pPkt)
Fail the session with the reason of the host.
float GetClockOffset() const
Definition joinpadrt.h:270
void RequestKey(int nHostAccount)
Ask the host for the key of the session.
bool OnMsg(ShareRemixPkt *pPkt)
Prepare the buffer of the remix the host shares.
JoinpadRT(MsgSink *pScreen, MsgSink *pGame, int nWorldId, int nHostAccount)
Construct the session, request the key from the host, and start mConnectTask.
const RemixInfo & GetRemixInfo() const
Definition joinpadrt.h:275
bool OnMsg(BootPkt *pPkt)
Exit when the host removed this console, and otherwise remove the guest.
ClockSyncTask * GetClockSync() const
Definition joinpadrt.h:260
void RemovePlayer(int nId) override
Remove a player who left, and exit the session when the host left.
~JoinpadRT() override
Stop and delete mClockSync, and clear TheJoinpadRT.
bool OnMsg(ClientInfoPkt *pPkt)
Enter a player of the session.
bool OnMsg(TimeResponsePkt *pPkt)
Pass the clock of the host to mClockSync.
int GetKeyReceived() const
Definition joinpadrt.h:255
bool OnMsg(ChatMsg *pMsg)
Take the key of the session the host sent.
bool OnMsg(WelcomePkt *pPkt)
Take the colour and the settings the host welcomed this console with.
void OnClockSynced(float fOffset, float fRoundTrip)
Take the offset of the clock of the host, and report this console ready when it can be.
void OnConnected() override
Report JoinLaunchpadSuccessMsg to the sink of mConnectTask.
bool OnMsg(GameOverPkt *pPkt)
Rate the game from the final scores, report them, and leave the game.
LaunchpadRT(MsgSink *pGame)
Construct the session, stored in TheNetLaunchpad and TheLaunchpadRT.
void NotifyLoaded() override
Report this console loaded.
bool OnMsg(ClientStatusPkt *pPkt)
Take the state of a player.
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:40
Receiver of engine messages.
Definition msgsink.h:21
The settings of an online game that the host publishes with its session.
Definition netgameparams.h:13
Description of a saved remix.
Definition remixinfo.h:26
Packet the host sends to offer the remix of the game to the guests.
Definition shareremixpkt.h:21
Packet that responds to a TimeRequestPkt with the clock of the responding console.
Definition timeresponsepkt.h:20
Packet the host sends a console that joins the session, with the colour of the console and the settin...
Definition welcomepkt.h:22
JoinpadRT * TheJoinpadRT
The joined session, or null.